Boost logo

Boost :

Subject: Re: [boost] expected/result/etc
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2016-01-28 15:02:45


On Wed, Jan 27, 2016 at 10:49 PM, Michael Marcin <mike.marcin_at_[hidden]>
wrote:

> So looking a few of these libraries/proposals I have a few things I'm
> interested in.
>
> - Is it at least as good as a simple hand-rolled solution?
> - Can you transport error codes through layers without knowing specifics
> of an error?
>
> For the second Niall's outcome/result handles very well I think.
> std::error_code and std::exception_ptr transport is good enough for almost
> any reasonable type agnostic error transport.
>

Have you considered using Boost Exception? It lets you add arbitrary data
to exception objects, even after they have been thrown, regardless of their
type -- see
http://www.boost.org/doc/libs/release/libs/exception/doc/error_info.html.
The general idea is to adopt a strategy where the exception objects are
augmented with any, even platform-specific relevant data, which then the
catch site can analyze to choose the correct handling.

Cheers,
Emil


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk