Thursday, March 5, 2015

Useful Custom Exceptions

One useful custom exception to cite as an example of "when would you use a custom exception" interview question is the ObjectNotFoundException triggered when accessing an invalid proxy gotten from the session.load() method. Custom exceptions are useful to for conditional logic that is strongly typed and semantically precise and, moreover, more natural then parsing and identifying error codes or String value properties of more generic exception types.