pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

Expose exception cause as std::nested_exception

Open ecatmur opened this issue 3 years ago • 0 comments

Description

Expose Python exception cause (raise ... from ...) to C++ via std::nested_exception. Inverse of #3608.

Useful after #3605 etc.

Does not set std::nested_exception base if a C++ exception is already present, for backwards compatibility if anyone is already using std::throw_with_nested(py::error_already_set()).

Suggested changelog entry:

`error_already_set` now inherits from `std::nested_exception` to expose the Python exception cause (`raise ... from ...`).

ecatmur avatar Jun 28 '22 14:06 ecatmur