Exceptions¶
To stop custom C++ exceptions from crashing the Python interpreter, list their
class names under exceptions. cppwg generates a pybind11 translator that catches
each one and re-raises it in Python as a RuntimeError carrying the exception’s
message. The message is read with what() by default; set message_method to
use a different accessor.
An entry may be a bare class name, or a mapping that overrides the message method:
exceptions:
- Exception # message read with what()
- name: CellsException
message_method: GetMessage # message read with GetMessage()
Caution
This only applies to thrown C++ exceptions. Errors from C dependencies that use
return codes (e.g. a PetscErrorCode) are not caught unless the underlying
C++ code converts them into a C++ exception first. See
PetscUtils::ThrowPetscError in the cells example.
See also
See the pybind11 docs on exceptions.
See Reference for a list of all configuration options.