Salome HOME
Merge branch 'master' into agy/NewPV1_For_850
[modules/gui.git] / src / SalomeApp / SalomeApp_ExceptionHandler.cxx
index b9e3139cb09411fc321c60323a89f264c833b24a..36534eee57ce1d151cae817deb0c3fd82a57c3c1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +21,7 @@
 //
 
 #include "SalomeApp_ExceptionHandler.h"
-
-#include "CASCatch.hxx"
-#include "Basics_OCCTVersion.hxx"
+#include "Utils_CorbaException.hxx"
 
 #include <OSD.hxx>
 
 
 #include <QString>
 
-#if OCC_VERSION_LARGE > 0x06010000
-  #include <Standard_ErrorHandler.hxx>
-  #include <Standard_Failure.hxx>
-#else
-  #include "CASCatch.hxx"
-#endif
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+
 
 /*!Constructor. Initialize by \a floatSignal.*/
 SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
@@ -56,24 +51,19 @@ SalomeApp_ExceptionHandler::SalomeApp_ExceptionHandler( const bool floatSignal )
 /*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
 bool SalomeApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e )
 {
-#if OCC_VERSION_LARGE > 0x06010000
-  try {
+  bool result = true;
+
+  try
+  {
     OCC_CATCH_SIGNALS;
-#else
-  CASCatch_TRY {
-#endif
-    SUIT_ExceptionHandler::internalHandle( o, e );
+    result = SUIT_ExceptionHandler::internalHandle( o, e );
   }
-#if OCC_VERSION_LARGE > 0x06010000
-  catch(Standard_Failure) {
-#else
-  CASCatch_CATCH(Standard_Failure) {
-#endif
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    throw Standard_Failure( aFail->GetMessageString() );
+  catch( Standard_Failure& e )
+  {
+    throw Standard_Failure( e.GetMessageString() );
   }
 
-  return true;
+  return result;
 }
 
 /*!Try to call handleSignals( o, e ), catch and show error message.*/
@@ -93,6 +83,10 @@ bool SalomeApp_ExceptionHandler::handle( QObject* o, QEvent* e )
   {
     showMessage( title, QString( e.GetMessageString() ) );
   }
+  catch( SALOME::SALOME_Exception& ex)
+  {
+    showMessage( title, QString( ex.details.text));
+  }
 #ifndef WIN32
   catch(...)
   {
@@ -110,13 +104,12 @@ extern "C" SALOMEAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
   // We disable FPE signal as it was in earlier versions of SALOME. It is enabled
   // only in debug mode if the environment variable DISABLE_FPE is not set to 1.
   bool raiseFPE;
-#if defined(_DEBUG_) | defined(_DEBUG) //the Last for WNT default settings
-  raiseFPE = true;
-  char* envDisableFPE = getenv("DISABLE_FPE");
-  if (envDisableFPE && atoi(envDisableFPE))
-    raiseFPE = false;
-#else
   raiseFPE = false;
+
+#if defined(_DEBUG_) | defined(_DEBUG) //the Last for WIN32 default settings
+  char* envEnableFPE = getenv("ENABLE_FPE");
+  if (envEnableFPE && atoi(envEnableFPE))
+    raiseFPE = true;
 #endif
 
   return new SalomeApp_ExceptionHandler( raiseFPE );