Forum Moderators: open

Message Too Old, No Replies

Error Handling - clearing exceptions

         

pedrodepacos

11:49 am on Mar 4, 2004 (gmt 0)

10+ Year Member



Hello,

I have nested try...catch statements that I use for error handling. I was wondering if there was any way to clear an error so that if an exception is encountered in a nested try...catch statement.

I've tried Err.Clear(), Server.ClearError(), Context.ClearError() and none of these work.

 
Try
'do something

Try
'do something

Catch DefaultExc As Exception
Context.ClearError()
Server.ClearError()
Err.Clear()

End Try

'the code here does not get processed when an error is caught in the try...catch statement above

Catch DefaultExc As Exception
'errors processed in the above catch statement always get processed here as well and I just want to clear the error in the first nested try...catch statement

End Try

wardbekker

9:48 am on Mar 5, 2004 (gmt 0)

10+ Year Member



If the two pieces of code throw different kinds of exceptions, use mutiple catch statements, each handeling a different exception type.

in pseudo:

try { somecodeA, andsomeothercodeB }
catch (nullrefenceExeption) { do this() }
catch (sqlservererror) { somethingdifferent() }