| 63 | // refer to pybind11 for the following exception handling helper |
| 64 | |
| 65 | inline void pybind11_translate_exception(std::exception_ptr last_exception) { |
| 66 | auto& registered_exception_translators = |
| 67 | pybind11::detail::get_internals().registered_exception_translators; |
| 68 | for (auto& translator : registered_exception_translators) { |
| 69 | try { |
| 70 | translator(last_exception); |
| 71 | } catch (...) { |
| 72 | last_exception = std::current_exception(); |
| 73 | continue; |
| 74 | } |
| 75 | return; |
| 76 | } |
| 77 | PyErr_SetString( |
| 78 | PyExc_SystemError, "Exception escaped from default exception translator!"); |
| 79 | } |
| 80 | |
| 81 | inline void pybind11_translate_exception() { |
| 82 | pybind11_translate_exception(std::current_exception()); |