Error Trapping
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   George_McLane
Posted On:   Monday, January 27, 2003 01:00 PM

Please use html tags to format code blocks.
Once I have trapped an error with try/catch, can I access my current local variables and/or the Call Stack so that I can add that information to my error log?

Re: Error Trapping

Posted By:   Jeanne_Boyarsky  
Posted On:   Monday, January 27, 2003 05:49 PM

It depends on where you declare the local variables.
If you do this, you can access the local variables:

int var;
String s;
try {
s = "hello";
var = Integer.parseInt(value);
} catch (Exception e) {
// do stuff
}

But if you do this, you can't:

try {
String s = "hello";
int var = Integer.parseInt(value);
} catch (Exception e) {
// do stuff
}

Basically, it's a scoping question. If you define the variables outside the scope of your try/catch block, you can access them.
About | Sitemap | Contact