Results 1 to 4 of 4

Thread: Error Handling - clearing an exception

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85

    Error Handling - clearing an exception

    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.

    Code:
     
    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 catch statement 
    
    End Try

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    The catch itself clears the exception, unless you throw it again.

    The code should run - are you sure an exception isn't being raised before the nested try...catch?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Posts
    85
    That's what I thought and I'm positive the exception is not being raised before the nested try...catch. The specific exception that I'm raising is ThreadAbortException from Server.Transfer(Path) or Response.Redirect(Path). Does this have anything to do with it?

  4. #4
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    That would have something to do with it - from MSDN (both HttpResponse.Redirect & Server.Transfer):

    Redirect calls End which raises a ThreadAbortException exception upon completion.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width