NBEngine/engine/NBCore/tests/testLogger.cpp
2026-05-02 03:37:06 -05:00

46 lines
1.0 KiB
C++

#include <exception>
#include "Errors.hpp"
#include "Logger.hpp"
class TestError : public nb::Error<TestError> {
using Base = Error<TestError>;
public:
using Base::Base;
using Base::what;
using Base::code;
using Base::msg;
using Base::trace;
enum Codes : unsigned int {
A, B, C, D
};
static const std::string type;
static const nb::ErrorCodeMap ErrorMessages;
};
const std::string TestError::type="TestError";
const nb::ErrorCodeMap TestError::ErrorMessages{
{TestError::Codes::A, "Hey!"},
{TestError::Codes::B, "How"},
{TestError::Codes::C, "You"},
{TestError::Codes::D, "Doin"}
};
int main() {
nb::logger.log("Whoop!");
try {
THROW(TestError(0, TestError(1, TestError(2, TestError(3, TestError(2))))));
} catch (TestError e){
nb::logger.log("nb::Error was thrown!");
}
try {
THROW(std::exception());
} catch (std::exception e){
nb::logger.log("std::exception was thrown!");
}
ERROR("hello there!");
return 0;
}