4 ms·
It looks pretty usable indeed, I just wish they had insludes std::error_code implementations for everything. Last time I checked, getting proper error_codes (i.
by stinos 7y ago
It looks pretty usable indeed, I just wish they had insludes std::error_code implementations for everything. Last time I checked, getting proper error_codes (i.e. which can be compared against standard categories and which have good error description strings) for everything in the API was still some manual work.
- aninteger 7y agoIt's not too hard. Just write a simple wrapper around FormatMessage: DWORD errorCode = GetLastError(); DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; LPTSTR lpMsgBuf = NULL; FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL); // Error message is in lpMsgBuf so make sure to free afterwards. LocalFree(lpMsgBuf);
- ksherlock 7y agoIt's even easier since the MSVC STL std::error_code (std::system_category) already does that.