diff --git a/include/Errors.hpp b/include/Errors.hpp index 151bca0..8edab0a 100644 --- a/include/Errors.hpp +++ b/include/Errors.hpp @@ -23,6 +23,29 @@ typedef std::unordered_map ErrorCodeMap; template class ErrorBase : public std::exception { public: + ErrorBase( + const unsigned int code, + unsigned int line=0, + std::string filename="" + ) noexcept : ErrorBase( + code, + ErrorBase::lookup(code), + line, + filename + ) {} + ErrorBase( + const unsigned int code, + const std::exception& trace, + unsigned int line=0, + std::string filename="" + ) noexcept : ErrorBase( + code, + ErrorBase::lookup(code), + trace, + line, + filename + ) {} + static std::string lookup(unsigned int); unsigned int code() const noexcept { return static_cast(this)->_code; @@ -71,29 +94,6 @@ protected: } _msg += "\n Trace: " + what_msg; } - ErrorBase( - const unsigned int code, - unsigned int line=0, - std::string filename="" - ) noexcept : ErrorBase( - code, - ErrorBase::lookup(code), - line, - filename - ) {} - - ErrorBase( - const unsigned int code, - const std::exception& trace, - unsigned int line=0, - std::string filename="" - ) noexcept : ErrorBase( - code, - ErrorBase::lookup(code), - trace, - line, - filename - ) {} unsigned int _code; std::string _msg; @@ -105,9 +105,10 @@ public: GENERAL, UNDEFINED, BADERRORCODE }; - Error(unsigned int code) : ErrorBase(code, ErrorBase::lookup(code)) {} - Error(unsigned int code, const std::exception& trace, unsigned int line=0, const std::string& filename="") - : ErrorBase(code, ErrorBase::lookup(code), trace, line, filename) {} + using ErrorBase::ErrorBase; + //Error(unsigned int code) : ErrorBase(code, ErrorBase::lookup(code)) {} + //Error(unsigned int code, const std::exception& trace, unsigned int line=0, const std::string& filename="") + // : ErrorBase(code, ErrorBase::lookup(code), trace, line, filename) {} friend ErrorBase; diff --git a/tests/ErrorTest/main.cpp b/tests/ErrorTest/main.cpp index 25e426d..f0eda15 100644 --- a/tests/ErrorTest/main.cpp +++ b/tests/ErrorTest/main.cpp @@ -7,11 +7,13 @@ using namespace nb; class TestError : public ErrorBase { public: - TestError(unsigned int code, unsigned int line=0, const std::string& filename="") - : ErrorBase(code, ErrorBase::lookup(code)) {} - TestError(unsigned int code, const std::exception& trace, unsigned int line=0, const std::string& filename="") - : ErrorBase(code, ErrorBase::lookup(code), trace, line, filename) {} + //TestError(unsigned int code, unsigned int line=0, const std::string& filename="") + // : ErrorBase(code, ErrorBase::lookup(code)) {} + //TestError(unsigned int code, const std::exception& trace, unsigned int line=0, const std::string& filename="") + // : ErrorBase(code, ErrorBase::lookup(code), trace, line, filename) {} + using ErrorBase::ErrorBase; + enum ErrorCodes : unsigned int { A, B, C, D };