From 630e6dbb1fc5d95aeb0eddc826e4a3e0784ee6ec Mon Sep 17 00:00:00 2001 From: Tristan 'Natrist' Cormier Date: Fri, 27 Jan 2023 11:25:57 -0500 Subject: [PATCH] feat(error): implement SErrSetLastError and SErrGetLastError functions --- storm/Error.cpp | 16 +++++++++++++++- storm/Error.hpp | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/storm/Error.cpp b/storm/Error.cpp index 3765bfe..bbbd3dc 100644 --- a/storm/Error.cpp +++ b/storm/Error.cpp @@ -3,6 +3,12 @@ #include #include +#if defined(WHOA_SYSTEM_WIN) +#include +#endif + +static uint32_t s_lasterror = ERROR_SUCCESS; + [[noreturn]] void SErrDisplayAppFatal(const char* format, ...) { va_list args; va_start(args, format); @@ -70,5 +76,13 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber) { } void SErrSetLastError(uint32_t errorcode) { - // TODO + s_lasterror = errorcode; + + #if defined(WHOA_SYSTEM_WIN) + SetLastError(errorcode); + #endif +} + +uint32_t SErrGetLastError() { + return s_lasterror; } diff --git a/storm/Error.hpp b/storm/Error.hpp index 057f655..75e8b9b 100644 --- a/storm/Error.hpp +++ b/storm/Error.hpp @@ -4,10 +4,11 @@ #include #if defined(WHOA_SYSTEM_WIN) -#include +#include #endif #if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX) +#define ERROR_SUCCESS 0x0 #define ERROR_INVALID_PARAMETER 0x57 #endif @@ -40,4 +41,6 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber); void SErrSetLastError(uint32_t errorcode); +uint32_t SErrGetLastError(); + #endif