diff options
author | fanquake <fanquake@gmail.com> | 2023-07-20 13:17:09 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-07-20 13:37:21 +0100 |
commit | ac7c1772f9a07585a3433173c3677b014d92feaf (patch) | |
tree | 240ae61a6902aecd212df198db9faddc66635ed6 /test/functional | |
parent | 1fde20faf8135d86633ffeaa9df0eea68f1d59ef (diff) | |
parent | 5408a55fc87350baeae3a32f1003f956d5533a79 (diff) |
Merge bitcoin/bitcoin#26654: util: Show descriptive error messages when FileCommit fails
5408a55fc87350baeae3a32f1003f956d5533a79 Consolidate Win32-specific error formatting (John Moffett)
c95a4432d7c9d0e5829cd802908700ba2e2c25dc Show descriptive error messages when FileCommit fails (John Moffett)
Pull request description:
Only raw [`errno`](https://en.cppreference.com/w/cpp/error/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, https://github.com/bitcoin/bitcoin/issues/26455#issue-1436654238 and [another](https://bitcointalk.org/index.php?topic=5182526.0#:~:text=FileCommit%3A%20FlushFileBuffers%20failed%3A%205).
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/1b680948d43b1d39645b9d839a6fa7c6c1786b51/src/util/sock.cpp#L390
https://github.com/bitcoin/bitcoin/blob/1b680948d43b1d39645b9d839a6fa7c6c1786b51/src/util/sock.cpp#L272
https://github.com/bitcoin/bitcoin/blob/7e1007a3c6c9a921c2b60919b84a60eaabfe1c5d/src/netbase.cpp#L515-L516
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](https://stackoverflow.com/questions/15586224/is-wsagetlasterror-just-an-alias-for-getlasterror).
ACKs for top commit:
MarcoFalke:
lgtm ACK 5408a55fc87350baeae3a32f1003f956d5533a79 💡
Tree-SHA512: 3921cbac98bd9edaf84d3dd7a43896c7921f144c8ca2cde9bc96d5fb05281f7c55e7cc99db8debf6203b5f916f053025e4fa741f51458fe2c53bb57b0a781027
Diffstat (limited to 'test/functional')
0 files changed, 0 insertions, 0 deletions