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_PLATFORM == TRINITY_PLATFORM_WINDOWS && !defined(EXCEPTION_ASSERTION_FAILURE)
56#define EXCEPTION_ASSERTION_FAILURE 0xC0000420L
59#define WPAssert(cond, ...) do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, GetDebugInfo(), ##__VA_ARGS__); } while(0)
60#define WPAssert_NODEBUGINFO(cond, ...) do { if (!(cond)) [[unlikely]] Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, ::GetDebugInfo(), ##__VA_ARGS__); } while(0)
61#define WPFatal(cond, ...) do { if (!(cond)) [[unlikely]] Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); } while(0)
62#define WPError(cond, msg) do { if (!(cond)) [[unlikely]] Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
63#define WPWarning(cond, msg) do { if (!(cond)) [[unlikely]] Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
64#define WPAbort() do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__); } while(0)
65#define WPAbort_MSG(msg, ...) do { Trinity::Abort(__FILE__, __LINE__, __FUNCTION__, (msg), ##__VA_ARGS__); } while(0)
67#ifdef PERFORMANCE_PROFILING
68#define ASSERT(cond, ...) ((void)0)
69#define ASSERT_NODEBUGINFO(cond, ...) ((void)0)
70#define ASSERT_NOTNULL(pointer) (pointer)
72#define ASSERT WPAssert
73#define ASSERT_NODEBUGINFO WPAssert_NODEBUGINFO
74#define ASSERT_NOTNULL(pointer) Trinity::Impl::AssertNotNull(pointer, __FILE__, __LINE__, __FUNCTION__, #pointer)
77#define ASSERT_WITH_SIDE_EFFECTS WPAssert
80#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