18#ifndef TRINITYCORE_ERRORS_H
19#define TRINITYCORE_ERRORS_H
28 [[noreturn]]
TC_COMMON_API void Assert(
char const* file,
int line,
char const* function,
char const* message, std::string debugInfo)
noexcept;
29 [[noreturn]]
TC_COMMON_API void Assert(
char const* file,
int line,
char const* function,
char const* message, std::string debugInfo,
char const* format, ...) noexcept
ATTR_PRINTF(6, 7);
33 [[noreturn]]
TC_COMMON_API void Error(
char const* file,
int line,
char const* function,
char const* message) noexcept;
35 [[noreturn]]
TC_COMMON_API void Abort(
char const* file,
int line,
char const* function) noexcept;
36 [[noreturn]]
TC_COMMON_API void Abort(
char const* file,
int line,
char const* function,
char const* message, ...) noexcept;
38 TC_COMMON_API void Warning(
char const* file,
int line,
char const* function,
char const* message) noexcept;
45 inline T*
AssertNotNull(T* pointer,
char const* file,
int line,
char const* function,
char const* message)
noexcept
47 if (pointer) [[likely]]
55#if TRINITY_COMPILER == TRINITY_COMPILER_MICROSOFT
56#define ASSERT_BEGIN __pragma(warning(push)) __pragma(warning(disable: 4127))
57#define ASSERT_END __pragma(warning(pop))
63#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
64#define EXCEPTION_ASSERTION_FAILURE 0xC0000420L
67#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, GetDebugInfo(), ##__VA_ARGS__); } while(0) ASSERT_END
68#define WPAssert_NODEBUGINFO(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, ::GetDebugInfo(), ##__VA_ARGS__); } while(0) ASSERT_END
69#define WPFatal(cond, ...) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0) ASSERT_END
70#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
71#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) [[unlikely]] Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
72#define WPAbort() ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0) ASSERT_END
73#define WPAbort_MSG(msg, ...) ASSERT_BEGIN do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0) ASSERT_END
75#ifdef PERFORMANCE_PROFILING
76#define ASSERT(cond, ...) ((void)0)
77#define ASSERT_NODEBUGINFO(cond, ...) ((void)0)
78#define ASSERT_NOTNULL(pointer) (pointer)
80#define ASSERT WPAssert
81#define ASSERT_NODEBUGINFO WPAssert_NODEBUGINFO
82#define ASSERT_NOTNULL(pointer) Trinity::Impl::AssertNotNull(pointer, __FILE__, __LINE__, __FUNCTION__, #pointer)
85#define ASSERT_WITH_SIDE_EFFECTS WPAssert
88#define ABORT_MSG WPAbort_MSG
#define ATTR_PRINTF(F, V)
COREDEBUG.
std::string GetDebugInfo()
TC_COMMON_API std::string GetDebugInfo()
T * AssertNotNull(T *pointer, char const *file, int line, char const *function, char const *message) noexcept
void Assert(char const *file, int line, char const *function, char const *message, std::string debugInfo) noexcept
void Error(char const *file, int line, char const *function, char const *message) noexcept
void Abort(char const *file, int line, char const *function) noexcept
void Fatal(char const *file, int line, char const *function, char const *message,...) noexcept
void AbortHandler(int sigval) noexcept