18#ifndef TRINITYCORE_ERRORS_H
19#define TRINITYCORE_ERRORS_H
26 [[noreturn]]
TC_COMMON_API void Assert(
char const* file,
int line,
char const* function, std::string debugInfo,
char const* message);
27 [[noreturn]]
TC_COMMON_API void Assert(
char const* file,
int line,
char const* function, std::string debugInfo,
char const* message,
char const* format, ...)
ATTR_PRINTF(6, 7);
31 [[noreturn]]
TC_COMMON_API void Error(
char const* file,
int line,
char const* function,
char const* message);
33 [[noreturn]]
TC_COMMON_API void Abort(
char const* file,
int line,
char const* function);
34 [[noreturn]]
TC_COMMON_API void Abort(
char const* file,
int line,
char const* function,
char const* message, ...);
36 TC_COMMON_API void Warning(
char const* file,
int line,
char const* function,
char const* message);
44#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
45#define ASSERT_BEGIN __pragma(warning(push)) __pragma(warning(disable: 4127))
46#define ASSERT_END __pragma(warning(pop))
52#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
53#define EXCEPTION_ASSERTION_FAILURE 0xC0000420L
56#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, GetDebugInfo(), #cond, ##__VA_ARGS__); } while(0) ASSERT_END
57#define WPAssert_NODEBUGINFO(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, "", #cond, ##__VA_ARGS__); } while(0) ASSERT_END
58#define WPFatal(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0) ASSERT_END
59#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
60#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
61#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
62#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END
64#ifdef PERFORMANCE_PROFILING
65#define ASSERT(cond, ...) ((void)0)
66#define ASSERT_NODEBUGINFO(cond, ...) ((void)0)
68#define ASSERT WPAssert
69#define ASSERT_NODEBUGINFO WPAssert_NODEBUGINFO
72#define ASSERT_WITH_SIDE_EFFECTS WPAssert
75#define ABORT_MSG WPAbort_MSG
80 ASSERT(pointer,
"%s", expr);
84#define ASSERT_NOTNULL(pointer) ASSERT_NOTNULL_IMPL(pointer, #pointer)
#define ATTR_PRINTF(F, V)
COREDEBUG.
std::string GetDebugInfo()
T * ASSERT_NOTNULL_IMPL(T *pointer, char const *expr)
void Assert(char const *file, int line, char const *function, std::string debugInfo, char const *message)
void AbortHandler(int sigval)
void Abort(char const *file, int line, char const *function)
void Fatal(char const *file, int line, char const *function, char const *message,...)
void Error(char const *file, int line, char const *function, char const *message)