| 116 | } |
| 117 | |
| 118 | [[noreturn]] void reportFatalErrorAndTerminate(std::string_view msg) |
| 119 | { |
| 120 | // Immediately terminate on re-entry. |
| 121 | static std::atomic<bool> entered; |
| 122 | if (entered.exchange(true) == true) |
| 123 | std::quick_exit(1); |
| 124 | |
| 125 | std::string fullMsg = fmt::format("{}\n\nStacktrace:\n{}", msg, getStackTrace(3)); |
| 126 | |
| 127 | logFatal(fullMsg); |
| 128 | |
| 129 | if (is_set(gErrorDiagnosticFlags, ErrorDiagnosticFlags::ShowMessageBoxOnError)) |
| 130 | { |
| 131 | enum ButtonId |
| 132 | { |
| 133 | Debug, |
| 134 | Abort |
| 135 | }; |
| 136 | |
| 137 | // Setup message box buttons |
| 138 | std::vector<MsgBoxCustomButton> buttons; |
| 139 | if (isDebuggerPresent()) |
| 140 | buttons.push_back({Debug, "Debug"}); |
| 141 | buttons.push_back({Abort, "Abort"}); |
| 142 | |
| 143 | // Show message box |
| 144 | auto result = msgBox("Fatal Error", fullMsg, buttons, MsgBoxIcon::Error); |
| 145 | if (result == Debug) |
| 146 | debugBreak(); |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | if (isDebuggerPresent()) |
| 151 | debugBreak(); |
| 152 | } |
| 153 | |
| 154 | std::quick_exit(1); |
| 155 | } |
| 156 | |
| 157 | FALCOR_SCRIPT_BINDING(Error) |
| 158 | { |
no test coverage detected