2025-11-05 00:21:11 -06:00

31 lines
643 B
C++

#include "Errors.hpp"
#include <iostream>
using namespace nb;
class TestError : public nb::Error {
public:
TestError(unsigned int code, nb::Error* const trace=nullptr) : _type("nb::TestError"), Error(code, ErrorCodeLookup<TestError>(code), trace) {}
friend const char* ErrorCodeLookup<TestError>(unsigned int);
protected:
static const nb::ErrorCodeMap ErrorCodes;
const char* _type;
};
const ErrorCodeMap TestError::ErrorCodes{
{0, "Hey!"},
{1, "How"},
{2, "You"},
{3, "Doin"}
};
int main() {
TestError a(0);
TestError b(1, &a);
TestError c(2, &b);
throw TestError(3, &c);
return 0;
}