Boost logo

Boost :

Subject: Re: [boost] [outcome] Ternary logic -- need an example
From: Bjorn Reese (breese_at_[hidden])
Date: 2017-05-20 10:12:20

On 05/19/2017 03:42 PM, Niall Douglas via Boost wrote:

> I have absolutely no idea why Chris chose "http_error" for that enum. It
> should have been "http_status" because those are the HTTP status codes
> as per


> I am also highly unsure why you'd choose the error_code infrastructure
> for these. It's not like almost all of the HTTP status codes (e.g. 306
> Switch Proxy) can be any error condition except
> resource_temporarily_unavailable.

When I perform an asynchronous HTTP operation that returns an error_code
then I prefer that the error_code contains a unified response, i.e. an
HTTP status code, a system error code (e.g. network problem), or an
internal library error code.

We can use the same solution as C++11 (std::system_category versus

   1. Define a native HTTP category that contains the raw HTTP status
      integer value.
   2. Define a generic HTTP category that contains enums for the HTTP
      status codes.
   3. Implement the equivalent() function on the native HTTP category
      that maps the native value to the enum.
   4. Mark the generic HTTP enum as an error condition.

That enables you to propagate the native value, so there is no loss of
information in case the HTTP status contains a hitherto unknown code,
and to compare it in a more user-friendly value using the enum.

You can find a tutorial here:

Boost list run by bdawes at, gregod at, cpdaniel at, john at