1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 // File : CASCatch_ErrorHandler.hxx
24 // Author : Sergey RUIN, Open CASCADE S.A.S (sergey.ruin@opencascade.com)
26 #ifndef CASCATCH_ERRORHANDLER_HXX
27 #define CASCATCH_ERRORHANDLER_HXX
29 #include "CASCatch_Failure.hxx"
35 extern int K_SETJMP_CASCatch ;
38 * \class CASCatch_ErrorHandler
39 * \brief This class is an exception handler, private
42 class CASCatch_ErrorHandler
44 friend class CASCatch_Failure; // To execute the raise exception.
48 Standard_EXPORT CASCatch_ErrorHandler();
49 Standard_EXPORT ~CASCatch_ErrorHandler();
50 Standard_EXPORT Standard_Boolean Catches (const Handle(Standard_Type)&);
53 Standard_EXPORT static void Abort();
54 Standard_EXPORT static void Error(const Handle(CASCatch_Failure)&);
55 Standard_EXPORT static Handle(CASCatch_Failure) LastCaughtError();
57 //==== The fields ===========================================================
59 CASCatch_ErrorHandler* Previous;
60 Handle(CASCatch_Failure) CaughtError;
68 #define CASCatch_TRY try
71 #define CASCatch_CATCH catch
74 #ifdef NO_CXX_EXCEPTION
76 # undef CASCatch_CATCH
78 # if defined(DO_ABORT)
80 # define DoesNotAbort_CASCatch(aHandler) !(K_SETJMP_CASCatch = setjmp(aHandler.Label))
82 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
83 K_SETJMP_CASCatch = 1 ; \
84 if(DoesNotAbort_CASCatch(_Function))
87 # define DoesNotAbort_CASCatch(aHandler) !setjmp(aHandler.Label)
89 # define CASCatch_TRY CASCatch_ErrorHandler _Function; \
90 if(DoesNotAbort_CASCatch(_Function))
94 # define CASCatch_CATCH(Error) else if(_Function.Catches(STANDARD_TYPE(Error)))
95 #endif // NO_CXX_EXCEPTION
97 #endif // CASCATCH_ERRORHANDLER_HXX