1

There are similar questions about On Error Goto x not catching all errors etc, but I've encountered a different problem.

My (Classic ASP) page works fine, most of the time. Some users complain of an error on the page, couldn't duplicate yet.

I tried error handling but On Error Resume Next does not help me with this situation and On Error Goto causes the page not to work and constantly throw an error (which looks like a 500, but that might be because of handling IIS is doing in background). It happens whether I write Goto 0 or Goto [label] without a difference if the label exists or not.

What might be causing this?

2 Answers 2

9

On Error GoTo label is not supported in ASP

you begin an error trapping block using

On Error Resume Next ,

check Err.Number to see if an error occurred,

close the block using

On Error GoTo 0.

See this doc and this thread

2
  • So, I need to If Err.Number <> 0 after each possible problem. And hope things work if I miss one of those...
    – JNF
    Nov 11, 2012 at 5:56
  • 1
    And remember to clear the Err object after a problem, if you want to carry on and check it again later! Jun 26, 2014 at 10:20
3

Trying to trap every error using On Error Resume Next is not practical in larger ASP pages.

Configure IIS to use a custom error page if a status code 500 is received. Format the following to suit...

Set objASPError = Server.GetLastError

response.write "Category: " & objASPError.Category & _
 "ASPCode: " & objASPError.ASPCode & _
 "Number: " & objASPError.Number & _
 "ASPDescription: " & objASPError.ASPDescription & _
 "Description: " & objASPError.Description & _
 "Source: " & objASPError.Source
2
  • It usually ends up without data for some reason
    – JNF
    May 20, 2013 at 9:09
  • Some nice include page with a Function/Sub named Catch is quite a nice way to do it. E.g. Sub Catch(errNumberExpected, friendlyError, bTerminateExecution, sOptionalRedirect) etc... On Error Resume Next ' Your code Catch 0, "Something went wrong when processing the submission", True, "Home.asp"
    – Mr AH
    May 7, 2014 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.