X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FError.hh;fp=src%2FMoof%2FException.hh;h=6dab32ffd07e14e93d8cbad3a6bc0620be5e4f7e;hp=8300746fc57c284411487e7548fbb100fadf73a8;hb=a295f8def17036c8071b56e181364f99a377cae7;hpb=b357615aba1dbde81e3c6999366604e6001010a7 diff --git a/src/Moof/Exception.hh b/src/Moof/Error.hh similarity index 73% rename from src/Moof/Exception.hh rename to src/Moof/Error.hh index 8300746..6dab32f 100644 --- a/src/Moof/Exception.hh +++ b/src/Moof/Error.hh @@ -26,30 +26,47 @@ *******************************************************************************/ -#ifndef _MOOF_EXCEPTION_HH_ -#define _MOOF_EXCEPTION_HH_ +#ifndef _MOOF_ERROR_HH_ +#define _MOOF_ERROR_HH_ -#include +#include // strncpy #include #include -#include - 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: *************************************************/