21 #include "Athena/Utility.hpp"
22 #include "Athena/Global.hpp"
25 #define __STR(x) __STRX(x)
26 #define __LINE_STRING__ __STR(__LINE__)
44 inline Exception(
const std::string&
message,
const std::string& file,
const std::string&
function,
const int line) :
49 m_exceptionName(
"Exception")
61 inline std::string file()
const
66 inline std::string
function()
const
71 inline int line()
const
76 inline std::string formattedMessage()
const
78 return Athena::utility::sprintf(
"%s : %s (%i) %s", m_file.c_str(), m_function.c_str(), m_line,
message().c_str());
83 std::string m_function;
85 std::string m_exceptionName;
90 #define THROW_EXCEPTION(args,...) \
92 if (atGetExceptionHandler()) {atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); return; \
93 } else { std::string msg = Athena::utility::sprintf(__VA_ARGS__); \
94 throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
97 #elif defined(__GNUC__)
98 #define THROW_EXCEPTION(args...) \
100 if (atGetExceptionHandler()) { atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return; \
102 std::string msg = Athena::utility::sprintf(args); \
103 throw Athena::error::Exception(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
109 #define THROW_EXCEPTION_RETURN(ret, args,...) \
111 if (atGetExceptionHandler()) \
113 atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, __VA_ARGS__); \
116 std::string msg = Athena::utility::sprintf(__VA_ARGS__); \
117 throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
120 #elif defined(__GNUC__)
121 #define THROW_EXCEPTION_RETURN(ret, args...) \
123 if (atGetExceptionHandler()) { atGetExceptionHandler()(__FILE__, AT_PRETTY_FUNCTION, __LINE__, args); return ret; \
125 std::string msg = Athena::utility::sprintf(args); \
126 throw Athena::error::Exception(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
131 #endif // EXCEPTION_HPP
Exception(const std::string &message, const std::string &file, const std::string &function, const int line)
The constructor for an Exception.
std::string message() const
Returns the Error message of the exception.
std::string m_message
The error message string.
The baseclass for all Exceptions.