| 124 | } |
| 125 | |
| 126 | void translatePythonException( bool withStacktrace ) |
| 127 | { |
| 128 | auto [exception, value, traceback] = currentPythonException(); |
| 129 | |
| 130 | // If the python exception is one bound via IECorePython::ExceptionClass, |
| 131 | // then we can extract and throw the C++ exception held internally. |
| 132 | if( PyObject_HasAttrString( value.get(), "__exceptionPointer" ) ) |
| 133 | { |
| 134 | object exceptionPointerMethod( handle<>( PyObject_GetAttrString( value.get(), "__exceptionPointer" ) ) ); |
| 135 | object exceptionPointerObject = exceptionPointerMethod(); |
| 136 | std::exception_ptr exceptionPointer = boost::python::extract<std::exception_ptr>( exceptionPointerObject )(); |
| 137 | std::rethrow_exception( exceptionPointer ); |
| 138 | } |
| 139 | |
| 140 | // Otherwise, we just throw a generic exception describing the python error. |
| 141 | throw IECore::Exception( formatInternal( exception, value, traceback, withStacktrace ) ); |
| 142 | } |
| 143 | |
| 144 | } // namespace ExceptionAlgo |
| 145 |
no test coverage detected