This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Where to catch exceptions
Posted by mitch gart on 14 Jul 1998, 9:46 AM
Bill Venners wrote:
> My own thought is that one should catch exceptions in the
> method that knows how to handle that exception, and that is
> usually going to be at the application level. Exceptions let
> you transfer control from the part of a program where an
> error or problem is detected to another part of the program
> that knows how to handle the error.
This is good as far as it goes but I wonder about how locally
you should catch exceptions. Suppose you have a method that
makes several calls to an API, and each call can throw a couple
of different exceptions. Do you put a little try-catch block
around each call, or a big one around the whole method? Any
style guidelines? Thanks.