From ca30e9b0a7e5ed7c0c5acc4839b2d56f1378d0b4 Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 9 Feb 2021 11:06:43 +0000 Subject: [PATCH] Error library now logs all errors before throw mainly done as I don't know how to fix throw for my os --- src/Error.cpp | 19 ++++++++++++++----- src/Error.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Error.cpp b/src/Error.cpp index ddfc31c..f01df3e 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -1,9 +1,18 @@ #include "Error.h" Error::Error(std::string location) { object = location; } -void Error::crash(std::string msg) { throw object + ": " + msg; } -void Error::crash(std::string reason, std::string msg) { - throw object + ": " + reason + ": " + msg; +void Error::crash(std::string msg) { + log("Error: " + msg); + throw object + ": \n" + msg; +} +void Error::crash(std::string reason, std::string msg) { + log("Error: " + reason + ": \n" + msg); + throw object + ": \n" + reason + ": \n" + msg; +} +void Error::warn(std::string msg) { + log("Warining: " + msg); + // throw object + ": " + msg; +} +void Error::log(std::string msg) { + std::cout << object << ": \n" << msg << std::endl; } -void Error::warn(std::string msg) { throw object + ": " + msg; } -void Error::log(std::string msg) { throw object + ": " + msg; } diff --git a/src/Error.h b/src/Error.h index 0d827c8..d5ec9d0 100644 --- a/src/Error.h +++ b/src/Error.h @@ -1,4 +1,5 @@ #pragma once +#include #include class Error {