22 #ifndef FIFE_EXCEPTION_H
23 #define FIFE_EXCEPTION_H
35 #include "util/log/logger.h"
57 virtual const char*
what()
const throw();
59 virtual const std::string& getTypeStr()
const {
static const std::string s =
"Exception";
return s; }
60 virtual const std::string& getDescription()
const {
static const std::string s =
"Generic FIFE exception";
return s; }
66 #define FIFE_EXCEPTION_DECL(_name, _description) \
67 class _name : public Exception { \
69 _name(const std::string& msg) : Exception(msg) { Logger _log(LM_EXCEPTION); FL_ERR(_log, what()); } \
70 const std::string& getTypeStr() const { static const std::string s = #_name; return s; } \
71 const std::string& getDescription() const { static const std::string s = _description; return s; } \
74 FIFE_EXCEPTION_DECL(SDLException,
"SDL reported something bad");
75 FIFE_EXCEPTION_DECL(NotFound,
"Something was searched, but not found");
76 FIFE_EXCEPTION_DECL(NotSet,
"Something was not set correctly");
77 FIFE_EXCEPTION_DECL(IndexOverflow,
"Someone tried to access a non-existing element");
78 FIFE_EXCEPTION_DECL(InvalidFormat,
"Found invalid data");
79 FIFE_EXCEPTION_DECL(CannotOpenFile,
"File couldn't be opened");
80 FIFE_EXCEPTION_DECL(InvalidConversion,
"Tried an invalid conversion");
81 FIFE_EXCEPTION_DECL(NotSupported,
"This action was not supported");
82 FIFE_EXCEPTION_DECL(NameClash,
"A name or identifier is already in use");
83 FIFE_EXCEPTION_DECL(Duplicate,
"A duplicate item was added, where this is not allowed");
84 FIFE_EXCEPTION_DECL(ScriptException,
"Error related to scripting functionality");
85 FIFE_EXCEPTION_DECL(EventException,
"Error related to event functionality");
86 FIFE_EXCEPTION_DECL(GuiException,
"Error related to gui functionality");
87 FIFE_EXCEPTION_DECL(InconsistencyDetected,
"An inconsistency in FIFE internals was detected. Please report this is a FIFE Bug.");
90 FIFE_EXCEPTION_DECL(OutOfMemory,
"Buy more ram ;)");