Variables to catch exceptions in the CATCH clause of TRY..CATCH

Variables to catch exceptions in the CATCH clause of TRY..CATCH

Post by Thilak » Fri, 23 Jul 2004 13:31:55


When using TRY .... CATCH, one can catch the exceptions to a variable using
the CATCH TO clause.
Thus one could write code such as follows,
TRY
<Code fragement, which can fail>
CATCH TO loEx1 WHEN ...

CATCH TO loEx2 WHEN ...

ENDTRY

In the above, two different variables are used to catch an exception, for 2
different conditions.

Which is best,
1. Using 2 different variables?
2. Or using the same variable names?

Regards,
Thilaka
 
 
 

Variables to catch exceptions in the CATCH clause of TRY..CATCH

Post by Sietse Wij » Fri, 23 Jul 2004 17:11:35

Hi Thalika.
IMHO there is no 'best' way, it's just a matter of taste
For readability, the 1st option is best
When you want to do something with the exeption in like logging the error,
the 2nd choice is better so you can place code in the finally to test for
the type of the var (Object if an error occured), and then log it.
HTH,
Sietse Wijnker




using
2