1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #include "SalomeApp_ExceptionHandler.h"
20 #include "CASCatch.hxx"
29 /*!Constructor. Initialize by \a floatSignal.*/
30 SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
31 : SUIT_ExceptionHandler()
33 OSD::SetSignal( floatSignal );
36 /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
37 bool SalomeApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e )
40 SUIT_ExceptionHandler::internalHandle( o, e );
42 CASCatch_CATCH(Standard_Failure) {
43 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
44 throw Standard_Failure( aFail->GetMessageString() );
50 /*!Try to call handleSignals( o, e ), catch and show error message.*/
51 bool SalomeApp_ExceptionHandler::handle( QObject* o, QEvent* e )
54 QString title( "Fatal error" );
57 res = handleSignals( o, e );
59 catch( std::exception& ex )
61 showMessage( title, QString( ex.what() ) );
63 catch( Standard_Failure& e )
65 showMessage( title, QString( e.GetMessageString() ) );
70 showMessage( title, "Unknown Exception" );
77 /*!Create new SUIT_ExceptionHandler*/
78 extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
80 // MSV 2006-04-26: work around PAL12004 "VTK window => SIGFPE Arithmetic Exception Detected"
81 // We disable FPE signal as it was in earlier versions of SALOME. It is enabled
82 // only in debug mode if the environment variable DISABLE_FPE is not set to 1.
86 char* envDisableFPE = getenv("DISABLE_FPE");
87 if (envDisableFPE && atoi(envDisableFPE))
92 return new SalomeApp_ExceptionHandler( raiseFPE );