Skip to content

Python Exceptions

Pydust provides utilities for raising builtin exception types as provided by the Stable API under PyExc_<name>.

1
2
3
pub fn raise_value_error(args: struct { message: py.PyString }) !void {
    return py.ValueError.raise(try args.message.asSlice());
}

Exceptions can be raise with any of the following:

  • .raise(message: [:0]const u8)
  • .raiseFmt(comptime fmt: [:0]const u8, args: anytype)
  • .raiseComptimeFmt(comptime fmt: [:0]const u8, comptime args: anytype)