|
Boost : |
Subject: Re: [boost] Noexcept
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-13 18:01:33
Emil Dotchevski wrote:
> If error codes are treated as "the error", then the error domain is
> limited to a single function. Consider these two functions:
>
> int f1(....); //returns 0 on success, 1-f1_error1, 2-f1_error2
> int f2(....); //returns 0 on success, 1-f2_error1, 2-f2_error2
>
> If f2 calls f1, if the error is communicated by an error code, f2 _must_
> translate the error condition from the domain of f1 errors, to the domain
> of f2 errors. And this must be done at every level, which introduces many
> points in the code where subtle errors may occur, and that is in error
> handling code which is very difficult to test and debug.
That's exactly the problem std::error_code solves, as it's a (code, domain)
pair, so there's no need to translate.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk