squall/storm/Error.hpp

44 lines
1.3 KiB
C++
Raw Normal View History

#ifndef STORM_ERROR_HPP
#define STORM_ERROR_HPP
#include <cstdint>
2020-12-02 20:04:02 -06:00
#if defined(WHOA_SYSTEM_WIN)
#include <winerror.h>
#endif
2020-12-02 20:04:02 -06:00
#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX)
#define ERROR_INVALID_PARAMETER 0x57
#endif
#if defined(NDEBUG)
2022-12-30 13:43:23 -06:00
#define STORM_ASSERT(x) \
(void)0
#else
#define STORM_ASSERT(x) \
if (!(x)) { \
SErrPrepareAppFatal(__FILE__, __LINE__); \
SErrDisplayAppFatal(#x); \
} \
(void)0
2022-12-30 13:43:23 -06:00
#endif
#define STORM_VALIDATE(x, y, ...) \
if (!(x)) { \
2022-12-30 13:43:23 -06:00
SErrSetLastError(y); \
return __VA_ARGS__; \
} \
(void)0
[[noreturn]] void SErrDisplayAppFatal(const char* format, ...);
int32_t SErrDisplayError(uint32_t errorcode, const char* filename, int32_t linenumber, const char* description, int32_t recoverable, uint32_t exitcode, uint32_t a7);
2020-12-08 23:37:22 -06:00
int32_t SErrDisplayErrorFmt(uint32_t errorcode, const char* filename, int32_t linenumber, int32_t recoverable, uint32_t exitcode, const char* format, ...);
void SErrPrepareAppFatal(const char* filename, int32_t linenumber);
void SErrSetLastError(uint32_t errorcode);
#endif