Made errors mostly work as hoped

This commit is contained in:
NaifBanana
2026-06-11 04:24:06 -05:00
parent d448b6724a
commit 0b473c0f8a
13 changed files with 284 additions and 142 deletions
+15 -16
View File
@@ -3,36 +3,35 @@
#include "Errors.hpp"
#include <gtest/gtest.h>
#include <iostream>
#include <sstream>
#include "Logger.hpp"
using namespace nb;
class TestError : public ErrorBase<TestError> {
class TestError : public Error<TestError> {
using Base = Error<TestError>;
public:
using ErrorBase<TestError>::ErrorBase;
using Base::Base;
using Base::what;
using Base::code;
using Base::msg;
using Base::trace;
enum ErrorCodes : unsigned int {
enum Codes : unsigned int {
A, B, C, D
};
static const std::string type;
static const ErrorCodeMap ErrorMessages;
static const nb::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"}
{TestError::Codes::A, "Hey!"},
{TestError::Codes::B, "How"},
{TestError::Codes::C, "You"},
{TestError::Codes::D, "Doin"}
};
TEST(ErrorTest, Test) {
EXPECT_EQ(1, 1);
std::stringstream sstream;
ASSERT_TRUE(nb::logger.isRunning());
nb::logger.log("Hey!");
std::cout << TestError(0, TestError(1, TestError(2))).what();
}