Julho 06
Prof(s). Eduardo Bezerra & Ismael H. F. Santos                                                2
Best Pratices for Using Exceptions
Gunjan Doshi - http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html
nExceptions due to programming errors
nIn this category, exceptions are generated due to programming errors (e.g., NullPointerException and IllegalArgumentException). The client code usually cannot do anything about programming errors.
n
nExceptions due to client code errors
nClient code attempts something not allowed by the API, and thereby violates its contract. The client can take some alternative course of action, if there is useful information provided in the exception. For example: an exception is thrown while parsing an XML document that is not well-formed. The exception contains useful information about the location in the XML document that causes the problem. The client can use this information to take recovery steps.
n
nExceptions due to resource failures
nExceptions that get generated when resources fail. For example: the system runs out of memory or a network connection fails. The client's response to resource failures is context-driven. The client can retry the operation after some time or just log the resource failure and bring the application to a halt.