#define CODE_ERROR_LOCATIONS #include "Errors.hpp" #include 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) {} enum ErrorCodes : unsigned int { A, B, C, D }; static const std::string type; static const ErrorCodeMap ErrorMessages; }; const std::string TestError::type="TestError"; const ErrorCodeMap TestError::ErrorMessages{ {TestError::ErrorCodes::A, "Hey!"}, {TestError::ErrorCodes::B, "How"}, {TestError::ErrorCodes::C, "You"}, {TestError::ErrorCodes::D, "Doin"} }; int main() { //TestError d(TestError::ErrorCodes::D, std::out_of_range("hey")); //TestError c(TestError::ErrorCodes::C, d); //TestError b(TestError::ErrorCodes::B, c); //TestError a(TestError::ErrorCodes::A, b); //throw Error(Error::ErrorCodes::UNDEFINED, a); try { try { try { try { THROW(TestError, TestError::ErrorCodes::D); } catch (const std::exception& e){ THROW(TestError, TestError::ErrorCodes::C, e); } } catch(const std::exception& e) { THROW(TestError, TestError::ErrorCodes::B, e); } } catch(const std::exception& e) { THROW(TestError, TestError::ErrorCodes::A, e); } } catch(const std::exception& e) { THROW(Error, Error::ErrorCodes::UNDEFINED, e); } return 0; }