Index of 500 Full Length Cartoons on YouTube Cracking WEP and WPA Wireless Networks
May 23

Bob Lee’s Blog: Exception Handling in Web Applications:

Solution: NestedException Failing early helps avoid these pitfalls. The original stack trace in addition to other pertinent state information (user IDs, primary keys, method arguments, etc.) is a troubleshooter’s best friend. I’ve found that when faced with a checked exception I can’t possibly handle, it’s best to wrap the exception in a runtime exception (once) and throw it to the top where it can ultimately be thrown to the web container. The exception propagates to the top sans explicit handling until the web container catches and logs it once and only once. We can accomplish this with a class called NestedException which I originally inherited from my friend and mentor Tim Williams and mentioned in my book Bitter EJB. NestedException wraps exceptions only when necessary (so we don’t end up with exceptions nested fifteen deep) and keeps the original stack trace intact. The catch block becomes: catch (CheckedException e) { throw NestedException.wrap(e); } NestedException consists of a simple wrapper class and static factory method, wrap(Throwable). NestedException overrides all methods to delegate to the wrapped exception (you don’t even need to unwrap it to get the message or stack trace you’re really interested in):

Comments are closed.

preload preload preload