1 // Copyright (C) 2007-2008 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
22 // File : CASCatch_ErrorHandler.hxx
23 // Author : Sergey RUIN, Open CASCADE S.A.S (sergey.ruin@opencascade.com)
25 #ifndef CASCATCH_ERRORHANDLER_HXX
26 #define CASCATCH_ERRORHANDLER_HXX
28 #include "CASCatch_Failure.hxx"
34 extern int K_SETJMP_CASCatch ;
37 * \class CASCatch_ErrorHandler
38 * \brief This class is an exception handler, private
41 class CASCatch_ErrorHandler
43 friend class CASCatch_Failure; // To execute the raise exception.
47 Standard_EXPORT CASCatch_ErrorHandler();
48 Standard_EXPORT ~CASCatch_ErrorHandler();
49 Standard_EXPORT Standard_Boolean Catches (const Handle(Standard_Type)&);
52 Standard_EXPORT static void Abort();
53 Standard_EXPORT static void Error(const Handle(CASCatch_Failure)&);
54 Standard_EXPORT static Handle(CASCatch_Failure) LastCaughtError();
56 //==== The fields ===========================================================
58 CASCatch_ErrorHandler* Previous;
59 Handle(CASCatch_Failure) CaughtError;
67 #define CASCatch_TRY try
70 #define CASCatch_CATCH catch
73 #ifdef NO_CXX_EXCEPTION
75 # undef CASCatch_CATCH
77 # if defined(DO_ABORT)
79 # define DoesNotAbort_CASCatch(aHandler) !(K_SETJMP_CASCatch = setjmp(aHandler.Label))
81 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
82 K_SETJMP_CASCatch = 1 ; \
83 if(DoesNotAbort_CASCatch(_Function))
86 # define DoesNotAbort_CASCatch(aHandler) !setjmp(aHandler.Label)
88 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
89 if(DoesNotAbort_CASCatch(_Function))
93 # define CASCatch_CATCH(Error) else if(_Function.Catches(STANDARD_TYPE(Error)))
94 #endif // NO_CXX_EXCEPTION
96 #endif // CASCATCH_ERRORHANDLER_HXX