pyd.exception
Contains utilities for safely wrapping python exceptions in D and vice versa.
- void
handle_exception
(string file = __FILE__, size_t line = __LINE__);
- This function first checks if a Python exception is set, and then (if one
is) pulls it out, stuffs it in a PythonException, and throws that exception.
If this exception is never caught, it will be handled by exception_catcher
(below) and passed right back into Python as though nothing happened.
- T
exception_catcher
(T)(T delegate() dg);
- It is intended that any functions that interface directly with Python which
have the possibility of a D exception being raised wrap their contents in a
call to this function, e.g.:
extern (C)
PyObject* some_func(PyObject* self) {
return exception_catcher({
// ...
});
}
- class
PythonException
: object.Exception;
- This simple exception class holds a Python exception.
|