| 17 | #endif |
| 18 | |
| 19 | void |
| 20 | assertFailed(const char *file, |
| 21 | unsigned line, |
| 22 | const char *expression, |
| 23 | const std::string &message) |
| 24 | { |
| 25 | auto stackTrace = platform::captureStackTrace(); |
| 26 | auto trace = platform::formatStackTrace(stackTrace); |
| 27 | platform::freeStackTrace(stackTrace); |
| 28 | |
| 29 | fmt::memory_buffer out; |
| 30 | fmt::format_to(std::back_inserter(out), "Assertion failed:\n"); |
| 31 | fmt::format_to(std::back_inserter(out), "Expression: {}\n", expression); |
| 32 | fmt::format_to(std::back_inserter(out), "File: {}\n", file); |
| 33 | fmt::format_to(std::back_inserter(out), "Line: {}\n", line); |
| 34 | |
| 35 | if (!message.empty()) { |
| 36 | fmt::format_to(std::back_inserter(out), "Message: {}\n", message); |
| 37 | } |
| 38 | |
| 39 | if (trace.size()) { |
| 40 | fmt::format_to(std::back_inserter(out), "Stacktrace:\n{}\n", trace); |
| 41 | } |
| 42 | out.push_back('\0'); |
| 43 | |
| 44 | gLog->critical("{}", out.data()); |
| 45 | std::cerr << out.data() << std::endl; |
| 46 | |
| 47 | #ifdef PLATFORM_WINDOWS |
| 48 | if (IsDebuggerPresent()) { |
| 49 | OutputDebugStringW(platform::toWinApiString(out.data()).c_str()); |
| 50 | } else { |
| 51 | auto wmsg = platform::toWinApiString(message); |
| 52 | auto expr = platform::toWinApiString(expression); |
| 53 | |
| 54 | if (!wmsg.empty()) { |
| 55 | expr += L"\nMessage: "; |
| 56 | expr += wmsg; |
| 57 | } |
| 58 | |
| 59 | _wassert(expr.c_str(), platform::toWinApiString(file).c_str(), line); |
| 60 | } |
| 61 | #endif |
| 62 | } |
| 63 | |
| 64 | void |
| 65 | assertWarnFailed(const char *file, |
nothing calls this directly
no test coverage detected