diff options
author | jackpoz <giacomopoz@gmail.com> | 2020-03-09 20:06:13 +0100 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2020-03-09 20:06:13 +0100 |
commit | 0ddee8a4a03fb5c7ee8d18144ca21cd2baad6f01 (patch) | |
tree | 18318b92038c2e50f30ae0398bdf2dcc7b11ffbc /src/common/Debugging/Errors.cpp | |
parent | e7d2489793fe919bf7f2e77fc67dbc556667efed (diff) |
Core/Common: Allow to show a message when aborting
Add a new ABORT_MSG macro that allows to show a formatted message before stopping the executable
Diffstat (limited to 'src/common/Debugging/Errors.cpp')
-rw-r--r-- | src/common/Debugging/Errors.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp index 5cb236419bd..295e61faee4 100644 --- a/src/common/Debugging/Errors.cpp +++ b/src/common/Debugging/Errors.cpp @@ -127,6 +127,20 @@ void Abort(char const* file, int line, char const* function) Crash(formattedMessage.c_str()); } +void Abort(char const* file, int line, char const* function, char const* message, ...) +{ + va_list args; + va_start(args, message); + + std::string formattedMessage = StringFormat("\n%s:%i in %s ABORTED:\n", file, line, function) + FormatAssertionMessage(message, args) + '\n'; + va_end(args); + + fprintf(stderr, "%s", formattedMessage.c_str()); + fflush(stderr); + + Crash(formattedMessage.c_str()); +} + void AbortHandler(int sigval) { // nothing useful to log here, no way to pass args |