Delete comment from: Javarevisited
Here are my 2 Cents on Exception best practices :
1) Consider Making Business Exception class as Immutable, to avoid any accidental change on Error. Make them final class, with all private final fields, initialized by constructor arguments.
2) Never Ever show Exception stacktrace in web pages, this is particularly important for Java developer, who writes JSP pages. Instead of showing Exception stacktrace to client, Use Global exception handler to show 404 page.
3) While writing your own Exception classes, both checked and unchecked, make sure you have provided methods to get exception, message, error code, which is required by clients for effective exception handling. Failing to do so may result in Client parsing error message and extracting relevant information, which results in ugly, brittle code.
Anyway Good list, Best practices are worth reading. Cheers
Jul 18, 2013, 12:55:28 AM
Posted to 10 Exception handling Best Practices in Java Programming