1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SalomeApp_ExceptionHandler.h"
25 #include "CASCatch.hxx"
26 #include "Basics_OCCTVersion.hxx"
35 #if OCC_VERSION_LARGE > 0x06010000
36 #include <Standard_ErrorHandler.hxx>
37 #include <Standard_Failure.hxx>
39 #include "CASCatch.hxx"
42 /*!Constructor. Initialize by \a floatSignal.*/
43 SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
44 : SUIT_ExceptionHandler()
46 // JFA 2006-09-28: PAL10867: suppress signal catching,
47 // if environment variable DISABLE_SIGNALS_CATCHING is set to 1.
48 // Commonly this is used with "noexcepthandler" option.
49 char* envNoCatchSignals = getenv("NOT_INTERCEPT_SIGNALS");
50 if (!envNoCatchSignals || !atoi(envNoCatchSignals))
52 OSD::SetSignal( floatSignal );
56 /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
57 bool SalomeApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e )
59 #if OCC_VERSION_LARGE > 0x06010000
65 SUIT_ExceptionHandler::internalHandle( o, e );
67 #if OCC_VERSION_LARGE > 0x06010000
68 catch(Standard_Failure) {
70 CASCatch_CATCH(Standard_Failure) {
72 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
73 throw Standard_Failure( aFail->GetMessageString() );
79 /*!Try to call handleSignals( o, e ), catch and show error message.*/
80 bool SalomeApp_ExceptionHandler::handle( QObject* o, QEvent* e )
83 QString title( "Fatal error" );
86 res = handleSignals( o, e );
88 catch( std::exception& ex )
90 showMessage( title, QString( ex.what() ) );
92 catch( Standard_Failure& e )
94 showMessage( title, QString( e.GetMessageString() ) );
99 showMessage( title, "Unknown Exception" );
106 /*!Create new SUIT_ExceptionHandler*/
107 extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
109 // MSV 2006-04-26: work around PAL12004 "VTK window => SIGFPE Arithmetic Exception Detected"
110 // We disable FPE signal as it was in earlier versions of SALOME. It is enabled
111 // only in debug mode if the environment variable DISABLE_FPE is not set to 1.
113 #if defined(_DEBUG_) | defined(_DEBUG) //the Last for WNT default settings
115 char* envDisableFPE = getenv("DISABLE_FPE");
116 if (envDisableFPE && atoi(envDisableFPE))
122 return new SalomeApp_ExceptionHandler( raiseFPE );