#ifndef ERROR_H #define ERROR_H #include class Error { public: Error(const std::string& s, const char* t, int c=-255) : error(s), type(t), code(c){} virtual ~Error(){} std::string error; std::string type; int code; }; #define DefineError(__Err__, __CODE__) class __Err__ : public Error{ public: __Err__(const std::string& e, const std::string& t) : Error(e, #__Err__, __CODE__){} ~__Err__(){} }; DefineError(ArgumentCommandError, -1) DefineError(NoPadSelectedError, -2) DefineError(ParseError, -3) DefineError(LexerError, -4) DefineError(NotFoundError, -5) DefineError(MalformedError, -6) DefineError(MidiError, -7) DefineError(UnknownError, -8) DefineError(ResponseOK, 0) #define THROW(__ERR__, __MSG__) {std::ostringstream os; os << #__ERR__<< " : " << __MSG__ <<"\n"; std::cerr << os.str(); throw __ERR__(os.str(), #__ERR__);} #endif // ERROR_H