in native/win-helper/win-helper.cpp [14:36]
void SetErrorMessage(const char* operationName, WCHAR*& errorMessagePtr) {
LPWSTR msg;
DWORD lastError = GetLastError();
FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
lastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&msg,
0,
NULL);
std::wstringstream s;
s << operationName << " failed with error " << lastError << ": ";
if (msg) {
s << msg;
LocalFree(msg);
}
else {
s << "(no message available)";
}
std::wstring copy(s.str());
errorMessagePtr = _wcsdup(copy.c_str());
}