Boost logo

Boost :

Subject: Re: [boost] expected/result/etc
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2016-01-29 18:47:20


On Fri, Jan 29, 2016 at 5:37 AM, Niall Douglas <s_sourceforge_at_[hidden]>
wrote:

> On 28 Jan 2016 at 16:57, Emil Dotchevski wrote:
>
> > Let's take socket errors for example, which on POSIX are communicated by
> > the OS through errno, while on Windows there is the GetLastError
> function.
> > Using the Boost Exception approach, you would always store the errno into
> > any socket exception object, and on Windows you'd also store the
> > GetLastError code. At the catch site, regardless of the platform, you can
> > put in logic that takes correct action based on the presence or absence
> of
> > any particular error_info:
>
> Doesn't std::system_error already do this for us, and it's already in
> the standard and it also allows arbitrary domain specific error
> coding?
>

My point is that perhaps it isn't arbitrary enough because there may be a
lot more than errno and GetLastError that is relevant to a given failure.
In the case of sockets, it may be necessary to transport a relevant URL to
the catch point, yet information like this isn't always available at the
point of the throw.

Obviously this is beyond the scope of std::system_error, I was just saying
that really exceptions or other error-reporting objects need to be able to
transport anything at all, especially in library-level code.

Emil


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