Try catch finally

  • Thread starter Thread starter Raj Chudasama
  • Start date Start date
R

Raj Chudasama

what is the extent to which you should use them? Shall i include them in
almost all methods ? pleaes direct me to where i can find some more
information

thanks
 
Raj,

Personally, I use try/finally when I know I have to clean up some things
in the face of anything. I only catch exceptions at the application
boundary, or when there is an exception that I would logically ^expect^ and
want to know if it happend. However, if I expect that it could happen, I
would argue that you should check for the state that the exception
represents beforehand (for example, instead of opening a file stream and
catching FileNotFoundException, check for the existence of the file first).

Hope this helps.
 
Raj Chudasama said:
what is the extent to which you should use them? Shall i include them in
almost all methods ? pleaes direct me to where i can find some more
information

thanks

Anytime you need to Handle an exception that may occur due to user-error or
system problems that may not occur should have an exception handler at the
point where you would like the exception to be handled. There should also
be a last-chance exception handler for those exceptions that trickle on by
previously undetected. This way, if there is a malfunction that is serious,
your application can still close gracefully and possibly let the user know
why the application needs to close (if it does at all).

Mythran
 
Back
Top