mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 10:32:29 +00:00
feat(error): implement SErrSetLastError and SErrGetLastError functions
This commit is contained in:
parent
095b042583
commit
630e6dbb1f
2 changed files with 19 additions and 2 deletions
|
|
@ -3,6 +3,12 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static uint32_t s_lasterror = ERROR_SUCCESS;
|
||||||
|
|
||||||
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...) {
|
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
|
|
@ -70,5 +76,13 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SErrSetLastError(uint32_t errorcode) {
|
void SErrSetLastError(uint32_t errorcode) {
|
||||||
// TODO
|
s_lasterror = errorcode;
|
||||||
|
|
||||||
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
|
SetLastError(errorcode);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t SErrGetLastError() {
|
||||||
|
return s_lasterror;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,11 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#if defined(WHOA_SYSTEM_WIN)
|
#if defined(WHOA_SYSTEM_WIN)
|
||||||
#include <winerror.h>
|
#include <WinError.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
|
||||||
|
#define ERROR_SUCCESS 0x0
|
||||||
#define ERROR_INVALID_PARAMETER 0x57
|
#define ERROR_INVALID_PARAMETER 0x57
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -40,4 +41,6 @@ void SErrPrepareAppFatal(const char* filename, int32_t linenumber);
|
||||||
|
|
||||||
void SErrSetLastError(uint32_t errorcode);
|
void SErrSetLastError(uint32_t errorcode);
|
||||||
|
|
||||||
|
uint32_t SErrGetLastError();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue