Subject: Re: [boost] expected/result/etc
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2016-01-30 09:51:26
On 29 Jan 2016 at 15:47, Emil Dotchevski wrote:
> > 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.
It's a fair point. I simply subclassed the exception type in question
and made it happy to get type sliced, but I'll grant you that
probably isn't best provided to library end users who tend to get
type slicing wrong as it is a bit brittle.
> 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.
Something I've always wished for is for std::exception to be able to
transport one or more stack backtraces. I rolled my own for AFIO v1
where it captures the stack both inside the engine and the stack
where end user code called AFIO code (both were always in different
threads), but it's a lot of code and is not efficient, and sadly will
not be present in AFIO v2 which is 98% noexcept and single threaded
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk