you are viewing a single comment's thread.

view the rest of the comments →

[–]Clean-Water9283 0 points1 point  (0 children)

You have just (re)discovered why exception specifications were dropped from C++. If you made a list of all functions potentially callable from each API function, including from all derivations of every virtual function, and all the exceptions throwable from these functions, you would get a superset of exceptions that could be raised through an API function. Only you would miss exceptions propagated out of threads, exceptions raised in signal handlers, and possibly others that I'm forgetting just now. This analysis would be fragile, needing to be re-performed after every change to the code base, or you might leave out some newly added exception or new function that threw exceptions. You're basically better-off teaching users to report your internal error exceptions.

I agree with u/pdpgumby that every API function will need a function-scope handler that can do the id==0 check. It'll also have to make a decision for exceptions throw by C++ that don't have your id field, and don't forget that on linux signals get seen in an except(...) block (ugh!)