Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:09:52

0001 #ifndef ATOOLS_Org_Exception_H
0002 #define ATOOLS_Org_Exception_H
0003 
0004 #include "ATOOLS/Org/Message.H"
0005 
0006 namespace ATOOLS {
0007 
0008   class Exception {
0009 
0010   private:
0011 
0012     std::string m_info, m_class, m_method, m_type;
0013 
0014   protected:
0015 
0016     const std::string& TypeName() const { return m_type; }
0017 
0018   public:
0019 
0020     Exception(const std::string& name="",
0021           const std::string& info="",
0022           const std::string& cmethod="");
0023 
0024     ~Exception() = default;
0025 
0026     friend std::ostream &operator<<(std::ostream &str,
0027                     const Exception &exception);
0028 
0029   };
0030 
0031   class normal_exit : public Exception {
0032   public:
0033     normal_exit(const std::string& info,
0034                 const std::string& cmethod)
0035       : Exception("Normal exit",
0036           info, cmethod) {}
0037   };
0038 
0039   class inconsistent_option : public Exception {
0040   public:
0041     inconsistent_option(const std::string& info,
0042                         const std::string& cmethod)
0043     : Exception("Inconsistent option",
0044         info, cmethod) {}
0045   };
0046 
0047   class not_implemented : public Exception {
0048   public:
0049     not_implemented(const std::string& info,
0050                     const std::string& cmethod)
0051       : Exception("Not implemented",
0052           info, cmethod) {}
0053   };
0054 
0055   class critical_error : public Exception {
0056   public:
0057     critical_error(const std::string& info,
0058                    const std::string& cmethod)
0059       : Exception("Critical error",
0060           info, cmethod) {}
0061   };
0062 
0063   class fatal_error : public Exception {
0064   public:
0065     fatal_error(const std::string& info,
0066                 const std::string& cmethod)
0067       : Exception("Fatal error",
0068           info, cmethod) {}
0069   };
0070 
0071   class missing_module : public Exception {
0072   public:
0073     missing_module(const std::string& info,
0074                    const std::string& cmethod)
0075       : Exception("Missing module",
0076           info, cmethod) {}
0077   };
0078 
0079   class missing_input : public Exception {
0080   public:
0081     missing_input(const std::string& info,
0082           const std::string& cmethod)
0083       : Exception("Missing input",
0084           info, cmethod) {}
0085   };
0086 
0087   class invalid_input : public Exception {
0088   public:
0089     invalid_input(const std::string& info,
0090           const std::string& cmethod)
0091       : Exception("Invalid input",
0092           info, cmethod) {}
0093   };
0094 
0095   class numerical_instability : public Exception {
0096   public:
0097     numerical_instability(const std::string& info,
0098               const std::string& cmethod)
0099       : Exception("Numerical instability",
0100           info, cmethod) {}
0101   };
0102 
0103 
0104   std::ostream &operator<<(std::ostream &str,const Exception &exception);
0105 
0106 }
0107 
0108 #if defined(__PRETTY_FUNCTION__)
0109 #define THROW(exception,message)             \
0110   throw(ATOOLS::exception(message,__PRETTY_FUNCTION__));
0111 #else
0112 #define THROW(exception,message)                    \
0113   throw(ATOOLS::exception(message,"<unknown class>::<unknown function>"));
0114 #endif
0115 
0116 #include "ATOOLS/Org/Stacktrace.H"
0117 
0118 #define DO_STACK_TRACE ATOOLS::GenerateStackTrace(std::cout)
0119 
0120 #endif