]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
exception handler for light package
authorasl <asl@opencascade.com>
Fri, 21 Apr 2006 07:33:11 +0000 (07:33 +0000)
committerasl <asl@opencascade.com>
Fri, 21 Apr 2006 07:33:11 +0000 (07:33 +0000)
src/LightApp/LightApp_ExceptionHandler.cxx [new file with mode: 0644]
src/LightApp/LightApp_ExceptionHandler.h [new file with mode: 0644]
src/LightApp/Makefile.in

diff --git a/src/LightApp/LightApp_ExceptionHandler.cxx b/src/LightApp/LightApp_ExceptionHandler.cxx
new file mode 100644 (file)
index 0000000..22a6b20
--- /dev/null
@@ -0,0 +1,81 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#include <LightApp_ExceptionHandler.h>
+#include "CASCatch.hxx"
+
+#include <OSD.hxx>
+
+#include <stdexcept>
+#include <exception>
+
+#include <qstring.h>
+
+/*!Constructor. Initialize by \a floatSignal.*/
+LightApp_ExceptionHandler::LightApp_ExceptionHandler( const bool floatSignal )
+: SUIT_ExceptionHandler()
+{
+  OSD::SetSignal( floatSignal );
+}
+
+/*!Try to call SUIT_ExceptionHandler::internalHandle(o, e), catch if failure.*/
+bool LightApp_ExceptionHandler::handleSignals( QObject* o, QEvent* e )
+{
+  CASCatch_TRY {   
+    SUIT_ExceptionHandler::internalHandle( o, e );
+  }
+  CASCatch_CATCH(Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();          
+    throw Standard_Failure( aFail->GetMessageString() );
+  }
+  
+  return true;
+}
+
+/*!Try to call handleSignals( o, e ), catch and show error message.*/
+bool LightApp_ExceptionHandler::handle( QObject* o, QEvent* e )
+{
+  bool res = false;
+  QString title( "Fatal error" );
+
+  try {
+    res = handleSignals( o, e );
+  }
+  catch( std::exception& ex )
+  {
+    showMessage( title, QString( ex.what() ) );
+  }
+  catch( Standard_Failure& e )
+  {
+    showMessage( title, QString( e.GetMessageString() ) );
+  }
+#ifndef WNT
+  catch(...)
+  {
+    showMessage( title, "Unknown Exception" );
+  }
+#endif
+
+  return res;
+}
+
+/*!Create new SUIT_ExceptionHandler*/
+extern "C" LIGHTAPP_EXPORT SUIT_ExceptionHandler* getExceptionHandler()
+{
+  return new LightApp_ExceptionHandler( true );
+}
diff --git a/src/LightApp/LightApp_ExceptionHandler.h b/src/LightApp/LightApp_ExceptionHandler.h
new file mode 100644 (file)
index 0000000..dcd0eda
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+// 
+// 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.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/
+//
+#ifndef LIGHTAPP_EXCEPTIONHANDLER_H
+#define LIGHTAPP_EXCEPTIONHANDLER_H
+
+#include <LightApp.h>
+#include <SUIT_ExceptionHandler.h>
+
+class LIGHTAPP_EXPORT LightApp_ExceptionHandler : public SUIT_ExceptionHandler
+{
+public:
+  LightApp_ExceptionHandler( const bool );
+  virtual bool handle( QObject*, QEvent* );
+
+protected:
+  virtual bool handleSignals( QObject*, QEvent* );
+};
+
+#endif
index c26adb88277cf96a7d0f07fa74787c0b083e2e06..f846930c051108bb0b3b28cf0269ae896027f249 100755 (executable)
@@ -22,6 +22,7 @@ EXPORT_HEADERS= LightApp.h \
                LightApp_Dialog.h \
                LightApp_Displayer.h \
                LightApp_Driver.h \
+               LightApp_ExceptionHandler.h \
                LightApp_HDFDriver.h \
                LightApp_Module.h \
                LightApp_ModuleDlg.h \
@@ -68,6 +69,7 @@ LIB_SRC= LightApp_AboutDlg.cxx \
         LightApp_Dialog.cxx \
         LightApp_Displayer.cxx \
         LightApp_Driver.cxx \
+        LightApp_ExceptionHandler.cxx \
         LightApp_HDFDriver.cxx \
         LightApp_Module.cxx \
         LightApp_ModuleDlg.cxx \