MCPcopy Create free account
hub / github.com/ImageEngine/cortex / translatePythonException

Function translatePythonException

src/IECorePython/ExceptionAlgo.cpp:126–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124}
125
126void 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

Callers 4

operator()Method · 0.85
handleMethod · 0.85
valueValidMethod · 0.85
readHeaderMethod · 0.85

Calls 3

currentPythonExceptionFunction · 0.85
formatInternalFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected