MCPcopy Create free account
hub / github.com/bwapi/bwapi / BWAPIError

Function BWAPIError

bwapi/BWAPI_PluginInjector/common.cpp:64–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64bool BWAPIError(const char *format, ...)
65{
66 // Format the variable argument list
67 char buffer[MAX_PATH];
68 va_list ap;
69 va_start(ap, format);
70 vsnprintf_s(buffer, MAX_PATH, MAX_PATH, format, ap);
71 va_end(ap);
72
73 // Get the last error and error message
74 wchar_t szErrMsg[MAX_PATH];
75 DWORD dwLastError = GetLastError();
76 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, szErrMsg, MAX_PATH, NULL);
77
78 std::wostringstream errorMessage;
79 errorMessage << buffer << '\n'
80 << "ID " << reinterpret_cast<void*>(dwLastError) << ": \n"
81 << szErrMsg << std::endl;
82
83 // Open a log file and print to it
84 std::wofstream log{ "bwapi-error.txt", std::ios::app };
85 if (log)
86 {
87 const time_t now = std::time(nullptr);
88 log << '[' << std::put_time(std::localtime(&now), L"%F %T") << "] " << errorMessage.str();
89 }
90
91 // Create a message box with the message and the error message
92 MessageBox(NULL, errorMessage.str().c_str(), NULL, MB_OK | MB_ICONERROR);
93 return false;
94}

Callers 3

ApplyPatchSuspendedFunction · 0.70
InitializePluginMethod · 0.70
RunConfigFunction · 0.70

Calls 1

c_strMethod · 0.80

Tested by

no test coverage detected