Only raw errno
int values are logged if FileCommit
fails. These values are implementation-specific, so it makes it harder to debug based on user reports. For instance, #26455#issue-1436654238 and another.
Instead, use SysErrorString
(or the refactored Windows equivalent Win32ErrorString
) to display both the raw int value and the descriptive message. All other instances in the code I could find where errno
or (Windows-only) GetLastError()
/WSAGetLastError()
are logged use the full descriptive string. For example:
https://github.com/bitcoin/bitcoin/blob/8ccab65f289e3cce392cbe01d5fc0e7437f51f1e/src/init.cpp#L164
I refactored the Windows formatting code to put it in syserror.cpp
, as it’s applicable to all Win32 API system errors, not just networking errors. To be clear, the Windows API functions WSAGetLastError()
and GetLastError()
are currently equivalent.