Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-04 09:15:58

0001 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Standard_DefineException_HeaderFile
0015 #define _Standard_DefineException_HeaderFile
0016 
0017 #include <Standard_SStream.hxx>
0018 
0019 #include <memory>
0020 
0021 //! @brief Defines an exception class inheriting from Standard_Failure.
0022 //!
0023 //! This macro creates a complete exception class with:
0024 //! - Constructors that forward to base class
0025 //! - ExceptionType() override returning the class name
0026 //!
0027 //! Usage:
0028 //! @code
0029 //! DEFINE_STANDARD_EXCEPTION(Standard_OutOfRange, Standard_RangeError)
0030 //! @endcode
0031 //!
0032 //! @param C1 Name of the exception class to define
0033 //! @param C2 Name of the parent exception class (must be Standard_Failure or derived)
0034 #define DEFINE_STANDARD_EXCEPTION(C1, C2)                                                          \
0035   class C1 : public C2                                                                             \
0036   {                                                                                                \
0037   public:                                                                                          \
0038     C1(const char* theMessage = "")                                                                \
0039         : C2(theMessage)                                                                           \
0040     {                                                                                              \
0041     }                                                                                              \
0042                                                                                                    \
0043     C1(const char* theMessage, const char* theStackTrace)                                          \
0044         : C2(theMessage, theStackTrace)                                                            \
0045     {                                                                                              \
0046     }                                                                                              \
0047                                                                                                    \
0048     const char* ExceptionType() const noexcept override                                            \
0049     {                                                                                              \
0050       return #C1;                                                                                  \
0051     }                                                                                              \
0052   };
0053 
0054 #endif