aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/shared/Debugging/Errors.cpp16
-rw-r--r--src/server/shared/Debugging/Errors.h4
2 files changed, 18 insertions, 2 deletions
diff --git a/src/server/shared/Debugging/Errors.cpp b/src/server/shared/Debugging/Errors.cpp
index 0621cfa5b6d..8b1b9454850 100644
--- a/src/server/shared/Debugging/Errors.cpp
+++ b/src/server/shared/Debugging/Errors.cpp
@@ -21,6 +21,7 @@
#include <cstdio>
#include <cstdlib>
#include <thread>
+#include <cstdarg>
namespace Trinity {
@@ -32,6 +33,21 @@ void Assert(char const* file, int line, char const* function, char const* messag
exit(1);
}
+void Assert(char const* file, int line, char const* function, char const* message, char const* format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s ", file, line, function, message);
+ vfprintf(stderr, format, args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
+
+ va_end(args);
+ *((volatile int*)NULL) = 0;
+ exit(1);
+}
+
void Fatal(char const* file, int line, char const* function, char const* message)
{
fprintf(stderr, "\n%s:%i in %s FATAL ERROR:\n %s\n",
diff --git a/src/server/shared/Debugging/Errors.h b/src/server/shared/Debugging/Errors.h
index 218acfa453e..f65d06cab01 100644
--- a/src/server/shared/Debugging/Errors.h
+++ b/src/server/shared/Debugging/Errors.h
@@ -23,8 +23,8 @@
namespace Trinity
{
-
DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
+ DECLSPEC_NORETURN void Assert(char const* file, int line, char const* function, char const* message, char const* format, ...) ATTR_NORETURN ATTR_PRINTF(5, 6);
DECLSPEC_NORETURN void Fatal(char const* file, int line, char const* function, char const* message) ATTR_NORETURN;
@@ -42,7 +42,7 @@ namespace Trinity
#define ASSERT_END
#endif
-#define WPAssert(cond) ASSERT_BEGIN do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while(0) ASSERT_END
+#define WPAssert(cond, ...) ASSERT_BEGIN do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond, __VA_ARGS__); } while(0) ASSERT_END
#define WPFatal(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPError(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END
#define WPWarning(cond, msg) ASSERT_BEGIN do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0) ASSERT_END