feat(storm): reorganized error library, assertions are now more detailed across different platforms; added new macros STORM_VALIDATE_STRING and STORM_PANIC

This commit is contained in:
phaneron 2024-08-30 18:04:21 -04:00
parent d149081f4e
commit 4f32840fdf
13 changed files with 164 additions and 103 deletions

35
storm/error/Macro.hpp Normal file
View file

@ -0,0 +1,35 @@
#ifndef STORM_ERROR_MACRO_HPP
#define STORM_ERROR_MACRO_HPP
#define STORM_NO_ERROR 0x85100000
#define STORM_ERROR(id) (STORM_NO_ERROR | (id & 0xFFFF))
// assertions
#if defined(NDEBUG)
#define STORM_ASSERT(x) \
(void)0
#else
#define STORM_ASSERT(x) \
if (!(x)) { \
SErrPrepareAppFatal(__FILE__, __LINE__); \
SErrDisplayAppFatal(#x); \
} \
(void)0
#endif
#define STORM_VALIDATE(x, y, ...) \
if (!(x)) { \
SErrSetLastError(y); \
return __VA_ARGS__; \
} \
(void)0
#define STORM_VALIDATE_STRING(x, y, ...) STORM_VALIDATE(x && *x, y, __VA_ARGS__)
#define STORM_PANIC(...) \
SErrPrepareAppFatal(__FILE__, __LINE__); \
SErrDisplayAppFatal(__VA_ARGS__); \
(void)0
#endif