1 #include "SalomeApp_ExceptionHandler.h"
5 #include <Standard_Failure.hxx>
6 #include <Standard_ErrorHandler.hxx>
13 #include <CASCatch_CatchSignals.hxx>
14 #include <CASCatch_ErrorHandler.hxx>
15 #include <CASCatch_Failure.hxx>
18 /*!Constructor. Initialize by \a floatSignal.*/
19 SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
20 : SUIT_ExceptionHandler()
22 OSD::SetSignal( floatSignal );
25 /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
26 bool SalomeApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e )
29 CASCatch_CatchSignals aCatchSignals;
30 aCatchSignals.Activate();
34 SUIT_ExceptionHandler::internalHandle( o, e );
36 CASCatch_CATCH(CASCatch_Failure) {
37 aCatchSignals.Deactivate();
38 Handle(CASCatch_Failure) aFail = CASCatch_Failure::Caught();
39 throw std::runtime_error( aFail->GetError() );
42 aCatchSignals.Deactivate();
54 /*!Try to call handleSignals( o, e ), catch and show error message.*/
55 bool SalomeApp_ExceptionHandler::handle( QObject* o, QEvent* e )
58 QString title( "Fatal error" );
61 res = handleSignals( o, e );
63 catch( std::exception& ex )
65 showMessage( title, QString( ex.what() ) );
67 catch( Standard_Failure& e )
69 showMessage( title, QString( e.GetMessageString() ) );
74 showMessage( title, "Unknown Exception" );
81 /*!Create new SUIT_ExceptionHandler*/
82 extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
84 return new SalomeApp_ExceptionHandler( true );