On 01/12/18 23:38, Peter Dimov via Boost wrote:
Andrey Semashev wrote:
I don't think this matches my intent. The `foo` function belongs to the domain that defines error codes described by the `my_errors` enum and it is supposed to return one of those codes. Preserving whatever error category was set in `err` on entry does not achieve that. What I want is that `err` has `my_category` unconditionally on return from `foo`.
In the general case, foo can call bar, which can also fail and return whatever error_code it likes. This is analogous to exceptions; mandating that functions from a specific domain only ever throw exceptions from that same domain quickly becomes burdensome.
I wouldn't say so. If I'm writing a library I would make it throw exceptions that belong to it. If it uses e.g. Boost.Filesystem then in the parts where it is used Boost.Filesystem can throw its own exceptions, which may propagate to the user. But in no case would I be throwing Boost.Filesystem exceptions myself from my library. It's the same with error codes. The only difference is that we have to have a success error code as well.