12 Jan
2018
12 Jan
'18
8:38 p.m.
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.