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
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