Working error system I believe
This commit is contained in:
@@ -5,7 +5,9 @@ using namespace nb;
|
||||
|
||||
class TestError : public ErrorBase<TestError> {
|
||||
public:
|
||||
TestError(unsigned int code, std::exception* const trace=nullptr)
|
||||
TestError(unsigned int code)
|
||||
: ErrorBase<TestError>(code, ErrorBase<TestError>::lookup(code)) {}
|
||||
TestError(unsigned int code, const std::exception& trace)
|
||||
: ErrorBase<TestError>(code, ErrorBase<TestError>::lookup(code), trace) {}
|
||||
|
||||
enum ErrorCodes : unsigned int {
|
||||
@@ -24,11 +26,11 @@ const ErrorCodeMap TestError::ErrorMessages{
|
||||
};
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user