34 lines
943 B
C++
34 lines
943 B
C++
#include "Errors.hpp"
|
|
#include <iostream>
|
|
|
|
using namespace nb;
|
|
|
|
class TestError : public ErrorBase<TestError> {
|
|
public:
|
|
TestError(unsigned int code, std::exception* const trace=nullptr)
|
|
: ErrorBase<TestError>(code, ErrorBase<TestError>::lookup(code), trace) {}
|
|
|
|
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);
|
|
TestError c(TestError::ErrorCodes::C, &d);
|
|
TestError b(TestError::ErrorCodes::B, &c);
|
|
TestError a(TestError::ErrorCodes::A, &b);
|
|
throw Error(Error::ErrorCodes::UNDEFINED, &a);
|
|
|
|
return 0;
|
|
} |