Can system_error be modified to add the numerical error code in the message?
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.2k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
We have logs that contain error messages in various languages like japanese, spanish, french, arabic, etc which causes our bug investigations to be difficult. Having a numerical error code would at least allow us to look up the message online.
Looking at the source, I think the following can be changed in the system_error file in the _System_error class:
Suggested:
static string _Makestr(error_code _Errcode, string _Message) { // compose error message
if (!_Message.empty()) {
_Message.append(": ");
}
_Message.append(to_string(_Errcode.value()));
_Message.append(" - ");
_Message.append(_Errcode.message());
return _Message;
}
When calling std::exception::what(), the error code would now be included.
This is just a proposition and I don't really mind the format itself. What's important is just the idea of adding the numerical code.
I wish it was possible to force FormatMessage to output english messages, but it doesn't work if the english package is not installed ☹️
Thanks,
Félix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked stl/inc/system_error implementation around lines 466-473 and inspect how _System_error builds its message and how std::exception::what() exposes it. Define a stable format for including the numerical error code, then verify that the resulting message preserves existing behavior while making the code available for multilingual logs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100