try
{
OCC_CATCH_SIGNALS
// do OCCT stuff
}
catch (const Standard_Failure& theErr)
{
Message::SendFail() << "OCCT exception caught:\n" << theErr;
}or in paranoid verbose mode:
try
{
// OCC_CATCH_SIGNALS is required on Linux platforms
// to catch signals (access violation and similar), activated by OSD::SetSignal()
OCC_CATCH_SIGNALS
// do OCCT stuff
}
catch (const Standard_Failure& theFailure)
{
TCollection_AsciiString anErr = TCollection_AsciiString ("OCCT exception caught:\n")
+ theFailure.GetMessageString() + " [" + theFailure.DynamicType()->Name() + "]";
Message::SendFail (anErr);
if (*theFailure.GetStackString() != '\0')
{
// print backtrace, managed by OSD::SetSignalStackTraceLength()
// and Standard_Failure::SetDefaultStackTraceLength()
Message::SendTrace (theFailure.GetStackString());
}
}
catch (const std::exception& theStdException)
{
TCollection_AsciiString anErr = TCollection_AsciiString ("STL exception caught:\n")
+ theStdException.what() + " [" + typeid(theStdException).name() + "]";
Message::SendFail (anErr);
}
catch (...)
{
TCollection_AsciiString anErr = "Unknown exception caught";
Message::SendFail (anErr);
}