| 57 | } // namespace Error |
| 58 | |
| 59 | [[noreturn]] void FatalError(const std::string &content, bool report) |
| 60 | { |
| 61 | Error::Impl::WriteStackTraceFile(); |
| 62 | |
| 63 | #if !defined APD_OS_WIN |
| 64 | #error "Need to port." |
| 65 | #endif |
| 66 | |
| 67 | // Because QMessageBox does not allow calls from non-GUI threads. |
| 68 | // So far, there seems to be no better way than using native APIs. |
| 69 | // |
| 70 | |
| 71 | auto title = std::format("{} fatal error", Config::ProgramName); |
| 72 | |
| 73 | if (report) { |
| 74 | auto message = std::format( |
| 75 | "An error has occurred!\n" |
| 76 | "Please help us fix this problem.\n" |
| 77 | "--------------------------------------------------\n" |
| 78 | "\n" |
| 79 | "{}\n" |
| 80 | "\n" |
| 81 | "--------------------------------------------------\n" |
| 82 | "Click \"Yes\" will pop up GitHub issue tracker page.\n" |
| 83 | "You can submit this information to us there.\n" |
| 84 | "Thank you very much.", |
| 85 | content); |
| 86 | |
| 87 | int button = MessageBoxA(nullptr, message.c_str(), title.c_str(), MB_ICONERROR | MB_YESNO); |
| 88 | |
| 89 | #if !defined APD_DEBUG |
| 90 | if (button == IDYES) { |
| 91 | QDesktopServices::openUrl(QUrl{Config::UrlIssues}); |
| 92 | } |
| 93 | #endif |
| 94 | } |
| 95 | else { |
| 96 | MessageBoxA(nullptr, content.c_str(), title.c_str(), MB_ICONERROR | MB_OK); |
| 97 | } |
| 98 | |
| 99 | #if defined APD_DEBUG |
| 100 | Utils::Debug::BreakPoint(); |
| 101 | #endif |
| 102 | |
| 103 | std::abort(); |
| 104 | } |
no test coverage detected