#ifndef ___ERROR_HPP__ #define ___ERROR_HPP__ #include #include std::string itos(int n) { std::string str = ""; while (n > 0) { str = (char)(int('0') + n % 10) + str; n = n / 10; } return str; } // base class Error { protected: std::string msg; public: Error(const std::string& func = "", const std::string& fname = "", int line = -1) { msg = ""; if (func != "") msg = "Function name: " + func; if (fname != "") msg = msg+ " in File: " + fname; if (line != -1) msg = msg + " at line:" + itos(line); } virtual std::string message() const { return "Error: " + msg; } }; #endif