|
Boost Users : |
From: Darren Garvey (lists.drrngrvy_at_[hidden])
Date: 2007-10-15 10:20:32
Hello,
I've been wondering for a while if it's sensible to use Boost.System for
transporting status_codes, rather than strictly error_codes. I'm aware than
I *may* be trying to misuse the system library here, so I'll get straight to
an example:
If I had an HTTP library that retrieved remote pages, I might want to use,
as (a very crude) example:
template<typename MutableBufferSequence>
void get_page(http::connection& conn, MutableBufferSequence& buf)
{
boost::system::error_code ec;
conn.get_page(buf, ec);
if (ec) throw ec;
}
The problem with relying on error_code to carry the errors is that the
various success codes (eg. 200 OK, 201 ACCEPTED, 202 CREATED, etc.) seem to
get lost, unless you class them as errors. Then you'd need something like:
- if (ec) throw ec;
+ if (ec >= http::ok || ec <= http::multi_status) throw ec;
It's not a massive pain, but having `ec == true` even when you don't have an
error isn't helpful. AFAICT, any non-zero error value is an error that'll
give `ec == true`.
I feel like I'm missing something here, please tell me if I am.
Regards,
Darren
PS. I'm trying to avoid having to make something that lies on top of
boost::system::error_code, like a status_code class.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net