[Base] Add wide versions of FatalError.

This commit is contained in:
gibbed 2019-08-04 03:26:18 -05:00
parent 29fcde6687
commit b685211b96
2 changed files with 23 additions and 0 deletions

View File

@ -335,6 +335,27 @@ void FatalError(const char* fmt, ...) {
exit(1);
}
void FatalError(const wchar_t* fmt, ...) {
va_list args;
va_start(args, fmt);
_vsnwprintf((wchar_t*)log_format_buffer_.data(),
log_format_buffer_.capacity() >> 1, fmt, args);
va_end(args);
LogLine(LogLevel::Error, 'X',
xe::to_string((wchar_t*)log_format_buffer_.data()));
#if XE_PLATFORM_WIN32
if (!xe::has_console_attached()) {
MessageBoxW(NULL, (wchar_t*)log_format_buffer_.data(), L"Xenia Error",
MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
}
#endif // WIN32
ShutdownLogging();
exit(1);
}
void FatalError(const std::string& str) { FatalError(str.c_str()); }
void FatalError(const std::wstring& str) { FatalError(str.c_str()); }
} // namespace xe

View File

@ -50,8 +50,10 @@ void LogLine(LogLevel log_level, const char prefix_char,
// Logs a fatal error with printf-style formatting and aborts the program.
void FatalError(const char* fmt, ...);
void FatalError(const wchar_t* fmt, ...);
// Logs a fatal error and aborts the program.
void FatalError(const std::string& str);
void FatalError(const std::wstring& str);
#if XE_OPTION_ENABLE_LOGGING
#define XELOGCORE(level, prefix, fmt, ...) \