Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's nothing wrong design-wise with your approach, IMO. I've seen several people (including very well-known C++ personalities) argue that exceptions should be used for X and error codes for Y, but this is just convention.

C++-wise, you probably want to catch std::exception and "..." too.

Finally, you said that there's two types of exceptions and only one of them is supposed to be reported to the user, but in your code you seem to report everything to the user. You should edit your message to clarify what you meant.



> C++-wise, you probably want to catch std::exception and "..." too.

Yeah, the "unknown_exception" in the above pseudocode represents that :)

> Finally, you said that there's two types of exceptions and only one of them is supposed to be reported to the user, but in your code you seem to report everything to the user. You should edit your message to clarify what you meant.

Yeah, only one will be reported because only one exception handler will be called. So the internal error will be reported to the user as "internal error" and some internal code that the user can report back to me if they want to. The other error is user error. So broadly there are only two categories of errors.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: