Boost logo

Boost :

Subject: Re: [boost] [outcome] Second high level summary of review feedback accepted so far
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2017-06-05 14:38:50


Le 05/06/2017 à 01:08, Peter Dimov via Boost a écrit :
> 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
>
> http://pdimov.com/cpp2/P0640R0.pdf
I'll take a look later.
>
> 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
> exception_info.
Oh, in this case it is clear that result<T> is not enough. We need
expected<T, filesystem::error>

where filesystem:error contains the error_code and the path.

Vicente


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