X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FError.hh;h=c452ae6df836f8351660b5cd0e460239f1932697;hb=e973a129b5b83b628ba3f09e8c95682fc74080cd;hp=6dab32ffd07e14e93d8cbad3a6bc0620be5e4f7e;hpb=a295f8def17036c8071b56e181364f99a377cae7;p=chaz%2Fyoink diff --git a/src/Moof/Error.hh b/src/Moof/Error.hh index 6dab32f..c452ae6 100644 --- a/src/Moof/Error.hh +++ b/src/Moof/Error.hh @@ -43,9 +43,11 @@ public: enum Code { - NONE = 0, + UNINITIALIZED = -1, // - + NONE = 0, // - ALC_INIT, // description FASTEVENTS_INIT, // description + OPENAL_INIT, // description FILE_NOT_FOUND, // path of missing file RESOURCE_NOT_FOUND, // name of missing resource SCRIPT_ERROR, // description @@ -55,7 +57,7 @@ public: UNKNOWN_IMAGE_FORMAT, // name of resource }; - explicit Error(unsigned code, const std::string& what = "") + explicit Error(unsigned code = NONE, const std::string& what = "") { init(code, what); } @@ -68,7 +70,7 @@ public: mCode = code; } - virtual void raise() + virtual void raise() const { throw *this; } @@ -83,11 +85,18 @@ public: return mWhat; } - bool isError() const throw() + operator bool () const { + // resolves to true if error code is not NONE return mCode != NONE; } + void reset() throw() + { + mCode = NONE; + mWhat[0] = '\0'; + } + private: unsigned mCode;