]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Error.hh
dispatch class not a singleton, engine is static
[chaz/yoink] / src / Moof / Error.hh
similarity index 73%
rename from src/Moof/Exception.hh
rename to src/Moof/Error.hh
index 8300746fc57c284411487e7548fbb100fadf73a8..6dab32ffd07e14e93d8cbad3a6bc0620be5e4f7e 100644 (file)
 
 *******************************************************************************/
 
-#ifndef _MOOF_EXCEPTION_HH_
-#define _MOOF_EXCEPTION_HH_
+#ifndef _MOOF_ERROR_HH_
+#define _MOOF_ERROR_HH_
 
-#include <cstring>
+#include <cstring>                     // strncpy
 #include <exception>
 #include <string>
 
-#include <Moof/Math.hh>
-
 
 namespace Mf {
 
 
-class Exception : public std::exception
+class Error : public std::exception
 {
 public:
 
-       explicit Exception(unsigned code, const std::string& what = "")
+       enum Code
+       {
+               NONE = 0,
+               ALC_INIT,                                       // description
+               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,           // name of resource
+               UNKNOWN_IMAGE_FORMAT,           // name of resource
+       };
+
+       explicit Error(unsigned code, const std::string& what = "")
+       {
+               init(code, what);
+       }
+       virtual ~Error() throw() {}
+
+       void init(unsigned code, const std::string& what = "")
        {
                mWhat[sizeof(mWhat)-1] = '\0';
                strncpy(mWhat, what.c_str(), sizeof(mWhat)-1);
                mCode = code;
        }
-       virtual ~Exception() throw() {}
 
        virtual void raise()
        {
@@ -66,32 +83,21 @@ public:
                return mWhat;
        }
 
+       bool isError() const throw()
+       {
+               return mCode != NONE;
+       }
+
 private:
 
        unsigned        mCode;
        char            mWhat[1024];
 };
 
-namespace ErrorCode {
-enum Code
-{
-       NONE = 0,
-       ALC_INIT,                                       // description
-       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,           // name of resource
-       UNKNOWN_IMAGE_FORMAT,           // name of resource
-};
-} // namespace ErrorCode
-
 
 } // namespace Mf
 
-#endif // _MOOF_EXCEPTION_HH_
+#endif // _MOOF_ERROR_HH_
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
This page took 0.022874 seconds and 4 git commands to generate.