Closed ohager closed 6 years ago
or we can use something like: https://github.com/Blagodarenko/miner-burst/blob/master/miner.cpp#L286 /* LPSTR DisplayErrorText( DWORD dwLastError ) {
HMODULE hModule = nullptr; // default to system source
LPSTR MessageBuffer = nullptr;
DWORD dwBufferLength;
DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM ;
if(dwLastError >= NERR_BASE && dwLastError <= MAX_NERR)
{
hModule = LoadLibraryEx( TEXT("netmsg.dll"), nullptr, LOAD_LIBRARY_AS_DATAFILE );
if(hModule != nullptr) dwFormatFlags |= FORMAT_MESSAGE_FROM_HMODULE;
}
dwBufferLength = FormatMessageA(dwFormatFlags, hModule, dwLastError, MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT), (LPSTR)&MessageBuffer, 0, nullptr);
if(hModule != nullptr) FreeLibrary(hModule);
return MessageBuffer;
} */
Haha, I didn't get the idea of that code... could you explain me the intend of that piece?! std::fprintf(std::stderr, ...)
is IMHO much clearer.
that piece translate errorcode to text info for default language (EN/RU/DE/ES/...)
Gotcha. That way you won't even write your own messages, but use those provided by the OS.
PR was merged. Closing issue.
Hi Blago,
another user encountered an issue with my autoplotter. For some reason XPlotter exited unsuccessfully, and returned a code only. It would be cewl if you could write your exceptions to
stderr
, such that it'll be easier to get the entire error messages.