exception.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_EXCEPTION_H
00023 #define FIFE_EXCEPTION_H
00024
00025
00026 #include <string>
00027 #include <stdexcept>
00028
00029
00030
00031
00032
00033
00034
00035
00036 namespace FIFE {
00037
00042 class Exception : public std::runtime_error {
00043 public:
00047 Exception(const std::string& msg);
00048
00051 virtual ~Exception() throw();
00052
00056 virtual const char* what() const throw();
00057
00058 virtual const std::string& getTypeStr() const { static const std::string s = "Exception"; return s; }
00059 virtual const std::string& getDescription() const { static const std::string s = "Generic FIFE exception"; return s; }
00060 };
00061
00062 #define FIFE_EXCEPTION_DECL(_name, _description) \
00063 class _name : public Exception { \
00064 public: \
00065 _name(const std::string& msg) : Exception(msg) {} \
00066 const std::string& getTypeStr() const { static const std::string s = #_name; return s; } \
00067 const std::string& getDescription() const { static const std::string s = _description; return s; } \
00068 }
00069
00070 FIFE_EXCEPTION_DECL(SDLException, "SDL reported something bad");
00071 FIFE_EXCEPTION_DECL(NotFound, "Something was searched, but not found");
00072 FIFE_EXCEPTION_DECL(NotSet, "Something was not set correctly");
00073 FIFE_EXCEPTION_DECL(IndexOverflow, "Someone tried to access a non-existing element");
00074 FIFE_EXCEPTION_DECL(InvalidFormat, "Found invalid data");
00075 FIFE_EXCEPTION_DECL(CannotOpenFile, "File couldn't be opened");
00076 FIFE_EXCEPTION_DECL(InvalidConversion, "Tried an invalid conversion");
00077 FIFE_EXCEPTION_DECL(NotSupported, "This action was not supported");
00078 FIFE_EXCEPTION_DECL(NameClash, "A name or identifier is already in use");
00079 FIFE_EXCEPTION_DECL(Duplicate, "A duplicate item was added, where this is not allowed");
00080 FIFE_EXCEPTION_DECL(ScriptException, "Error related to scripting functionality");
00081 FIFE_EXCEPTION_DECL(EventException, "Error related to event functionality");
00082 FIFE_EXCEPTION_DECL(GuiException, "Error related to gui functionality");
00083 FIFE_EXCEPTION_DECL(InconsistencyDetected, "An inconsistency in FIFE internals was detected. Please report this is a FIFE Bug.");
00084
00086 FIFE_EXCEPTION_DECL(OutOfMemory, "Buy more ram ;)");
00087
00088
00089 }
00090
00091 #endif