25 #ifndef __I6ENGINE_UTILS_EXCEPTIONS_EXCEPTIONS_H__
26 #define __I6ENGINE_UTILS_EXCEPTIONS_EXCEPTIONS_H__
31 #include "boost/exception/all.hpp"
33 #define ISIXE_THROW_SUBSYSTEM(module, message) {\
34 std::stringstream logMessageString;\
35 logMessageString << message;\
36 throw i6e::utils::exceptions::SubsystemException(module, logMessageString.str(), __FILE__, __LINE__);\
39 #define ISIXE_THROW_FAILURE(module, message) {\
40 std::stringstream logMessageString;\
41 logMessageString << message;\
42 throw i6e::utils::exceptions::SystemFailureException(module, logMessageString.str(), __FILE__, __LINE__);\
45 #define ISIXE_THROW_API(module, message) {\
46 std::stringstream logMessageString;\
47 logMessageString << message;\
48 throw i6e::utils::exceptions::ApiException(module, logMessageString.str(), __FILE__, __LINE__);\
51 #define ISIXE_THROW_MESSAGE(module, message) {\
52 std::stringstream logMessageString;\
53 logMessageString << message;\
54 throw i6e::utils::exceptions::MessageException(module, logMessageString.str(), __FILE__, __LINE__);\
57 #define ISIXE_THROW_API_COND(module, message, condition) {\
59 ISIXE_THROW_API(module, message)\
66 #define ISIXE_THROW_API_INFO(module, message, info) {\
67 std::stringstream logMessageString;\
68 logMessageString << message << "\nPossible solutin: " << info;\
69 throw i6e::utils::exceptions::ApiException(module, logMessageString.str(), __FILE__, __LINE__);\
74 namespace exceptions {
87 loginfo(
const LogLevel l,
const std::string & msg,
const std::string & m,
const std::string & f,
const uint16_t li) : level(l), message(msg), module(m), file(f), line(li) {
91 typedef boost::error_info<struct tag_logmessage, loginfo>
excinfo_log;
99 struct i6exception :
virtual boost::exception,
virtual std::exception {
117 i6exception(
const LogLevel loglevel,
const std::string & logmodule,
const std::string & logmsg,
const std::string & file,
const uint16_t line);
155 ISIXE_UTILS_API ApiException(
const std::string & logmodule,
const std::string & logmsg,
const std::string & file,
const uint16_t line);
ISIXE_UTILS_API void PassToMain()
Passes the exception from the subsystem to the main game loop.
LogLevel
Defines values to specify severity/importance of log message.
Internal data structure for exceptions.
loginfo(const LogLevel l, const std::string &msg, const std::string &m, const std::string &f, const uint16_t li)
ISIXE_UTILS_API int getErrorcode()
Returns the exception's errorcode or -1 if no errorcode is present.
virtual ISIXE_UTILS_API const char * what() const override
Overrides std::exception method to output message to console.
ISIXE_UTILS_API MessageException(const std::string &logmodule, const std::string &logmsg, const std::string &file, const uint16_t line)
ISIXE_UTILS_API SystemFailureException(const std::string &logmodule, const std::string &logmsg, const std::string &file, const uint16_t line)
ISIXE_UTILS_API void writeLog()
Writes the exception's logmessage.
Critical exception that cannot be repaired by a single subsystem.
Non-fatal, potentially reparable exception within a single subsystem.
Occurs when the engine detects a programmer's error.
boost::error_info< struct tag_logmessage, loginfo > excinfo_log
Base type for custom exceptions.
ISIXE_UTILS_API SubsystemException(const std::string &logmodule, const std::string &logmsg, const std::string &file, const uint16_t line)
Occurs when a wrong message is detected.
i6exception(const LogLevel loglevel, const std::string &logmodule, const std::string &logmsg, const std::string &file, const uint16_t line)
ISIXE_UTILS_API ApiException(const std::string &logmodule, const std::string &logmsg, const std::string &file, const uint16_t line)