Reporting correct names for windows error codes #7885
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the correct exit code name reporting on Windows. For example, for the error code -1073741819, we should get the "STATUS_ACCESS_VIOLATION" name with this PR. In the future, it will also be possible to show more detailed error descriptions if necessary.
As it turns out, no available API or library maps Windows error codes to error names. It is possible to read the complete list of Windows error codes here: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55, but it is not available in a convenient way to use in an application code.
I parsed the list of errors and stored them as a file win_error_codes.txt. In this file, for each error we have a numeric code, an error name and a detailed description, separated by spaces. It was possible to use a more structured format, like JSON or CSV, but I prefer the plain text format as it is easy to parse and allows us to quickly see the diff if some errors will be added in the future.