Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:15:06

0001 #ifndef hcal_Exception_hh_included
0002 #define hcal_Exception_hh_included 1
0003 
0004 #ifdef HAVE_XDAQ
0005 #include "xcept/Exception.h"
0006 #else
0007 #include <exception>
0008 #include <string>
0009 #endif
0010 
0011 namespace hcal {
0012   namespace exception {
0013 #ifdef HAVE_XDAQ
0014     class Exception : public xcept::Exception {
0015     public:
0016       Exception(const std::string& name,
0017                 const std::string& message,
0018                 const std::string& module,
0019                 int line,
0020                 const std::string& function)
0021           : xcept::Exception(name, message, module, line, function) {}
0022 
0023       Exception(const std::string& name,
0024                 const std::string& message,
0025                 const std::string& module,
0026                 int line,
0027                 const std::string& function,
0028                 xcept::Exception& e)
0029           : xcept::Exception(name, message, module, line, function, e) {}
0030     };
0031 #else
0032     class Exception : public std::exception {
0033     public:
0034       Exception(const std::string& name,
0035                 const std::string& message,
0036                 const std::string& module,
0037                 int line,
0038                 const std::string& function)
0039           : Exception(message) {}
0040       Exception(const std::string& message) : message_(message) {}
0041 
0042       const char* what() const throw() override { return message_.c_str(); }
0043 
0044     private:
0045       std::string message_;
0046     };
0047 
0048 #define XCEPT_RAISE(EXCEPTION, MSG) throw EXCEPTION(#EXCEPTION, MSG, __FILE__, __LINE__, __FUNCTION__)
0049 
0050 #endif
0051   }  // namespace exception
0052 }  // namespace hcal
0053 
0054 #endif  // hcal_Exception_hh_included