Boost logo

Boost :

Subject: Re: [boost] [outcome] Second high level summary of review feedback accepted so far
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-04 23:08:59

Vicente J. Botet Escriba wrote:
> Wrap E so that the conversion to Exception can be done, e.g. instead of
> std::result<bool> we could have expected<bool, filesystem::error_code>
> filesystem::error_code is a wrapper for error_code that defines the
> rethrow function throwing filesystem_error.

The problem here is not just that we have to throw filesystem_error; the
problem is that the point of throwing filesystem_error instead of
system_error is that it contains the path (two paths even, although we only
have one in this case), and there's no path in error_code.

If all we had was error_code, the right exception to throw is system_error,
because that's what it's for.

The correct approach here, I think, is not to define fat error codes, but to
return an outcome whose error() is the error_code and whose exception() is
the appropriate filesystem_error exception, complete with the path(s).

Setting however both the error_code and the exception_ptr is not supported
by the current outcome design (and neither would it be supported by
expected<R, error_code, exception_ptr>.)

Or, an alternative that scales better would be to take

and store error_code and exception_info, so that later one can use

    throw_with_info( std::system_error( error() ), info );

with the additional information (such as paths) being carried by the

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