On Tuesday, July 7th, 2026 at 12:21 AM, Andrzej Krzemienski via Boost <boost@lists.boost.org> wrote:
Just to note here that this is an important observation and one I'd like to reiterate. "error codes are for errors" is a common misconception in this space.
Any idea where this misconception may be coming from?
I think std::error_code provides the right functionality with a poor label and I suspect the label is exactly where the misconception comes from. People see "error" in the type name and assume any non-zero value signals a failure. A better name would be "status_code". There are many times when we want to express the state of something that is neither success nor failure, like peer_not_ready or block_not_linkable, where the program should do something other than either carry on as if all is well or treat it as a failure. I don't think I'm alone in this opinion. There is actually a paper P1028 that describes this idea. I also believe Boost's error_code provides a query to determine if the code actually indicates a failure, which further validates the line of thought.