47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#define CODE_ERROR_LOCATIONS
|
|
|
|
#include "Errors.hpp"
|
|
#include <iostream>
|
|
|
|
using namespace nb;
|
|
|
|
class TestError : public ErrorBase<TestError> {
|
|
public:
|
|
using ErrorBase<TestError>::ErrorBase;
|
|
|
|
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() {
|
|
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;
|
|
} |