#ifndef _MOOF_EXCEPTION_HH_
#define _MOOF_EXCEPTION_HH_
+#include <cstring>
#include <exception>
-#include <boost/shared_ptr.hpp>
+
+#include <Moof/Math.hh>
namespace Mf {
-struct Exception : public std::exception
+class Exception : public std::exception
{
- enum
+public:
+
+ explicit Exception(unsigned code, const char* what = "")
{
- FILE_NOT_FOUND = 1,
- OPENGL_ERROR = 2,
- OPENAL_ERROR = 3,
- SDL_ERROR = 4
- };
-
- explicit Exception(unsigned error) :
- code(error) {}
+ mWhat[sizeof(mWhat)-1] = '\0';
+ strncpy(mWhat, what, sizeof(mWhat)-1);
+ mCode = code;
+ }
virtual ~Exception() throw() {}
virtual void raise()
throw *this;
}
- virtual const char* what() const throw()
+ unsigned code() const throw()
+ {
+ return mCode;
+ }
+
+ const char* what() const throw()
{
- switch (code)
- {
- case FILE_NOT_FOUND:
- return "file not found";
- case OPENGL_ERROR:
- return "opengl error";
- case OPENAL_ERROR:
- return "openal error";
- case SDL_ERROR:
- return "sdl error";
- }
- return "unknown error";
+ return mWhat;
}
- unsigned code;
+private:
+
+ unsigned mCode;
+ char mWhat[1024];
+};
+
+namespace ErrorCode {
+enum Code
+{
+ NONE = 0,
+ FASTEVENTS_INIT, // description
+ FILE_NOT_FOUND, // path of missing file
+ RESOURCE_NOT_FOUND, // name of missing resource
+ SCRIPT_ERROR, // description
+ SDL_INIT, // description
+ SDL_VIDEOMODE, // -
+ UNKNOWN_AUDIO_FORMAT, // -
+ UNKNOWN_IMAGE_FORMAT, // -
};
+} // namespace ErrorCode
} // namespace Mf