1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #ifndef _CASCatch_ErrorHandler_HeaderFile
22 #define _CASCatch_ErrorHandler_HeaderFile
24 #include "CASCatch_Failure.hxx"
30 extern int K_SETJMP_CASCatch ;
33 * \class CASCatch_ErrorHandler
34 * \brief This class is an exception handler, private
37 class CASCatch_ErrorHandler
39 friend class CASCatch_Failure; // To execute the raise exception.
43 Standard_EXPORT CASCatch_ErrorHandler();
44 Standard_EXPORT ~CASCatch_ErrorHandler();
45 Standard_EXPORT Standard_Boolean Catches (const Handle(Standard_Type)&);
48 Standard_EXPORT static void Abort();
49 Standard_EXPORT static void Error(const Handle(CASCatch_Failure)&);
50 Standard_EXPORT static Handle(CASCatch_Failure) LastCaughtError();
52 //==== The fields ===========================================================
54 CASCatch_ErrorHandler* Previous;
55 Handle(CASCatch_Failure) CaughtError;
63 #define CASCatch_TRY try
66 #define CASCatch_CATCH catch
69 #ifdef NO_CXX_EXCEPTION
71 # undef CASCatch_CATCH
73 # if defined(DO_ABORT)
75 # define DoesNotAbort_CASCatch(aHandler) !(K_SETJMP_CASCatch = setjmp(aHandler.Label))
77 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
78 K_SETJMP_CASCatch = 1 ; \
79 if(DoesNotAbort_CASCatch(_Function))
81 # else //If DO_ABORT is not defined
82 # define DoesNotAbort_CASCatch(aHandler) !setjmp(aHandler.Label)
84 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
85 if(DoesNotAbort_CASCatch(_Function))
89 # define CASCatch_CATCH(Error) else if(_Function.Catches(STANDARD_TYPE(Error)))
90 #endif //NO_CXX_EXCEPTION
92 #endif //_CASCatch_ErrorHandler_HeaderFile