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?

JNF
  • 3,696
  • 3
  • 31
  • 64

2 Answers2

8

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

Community
  • 1
  • 1
Flakes
  • 2,422
  • 8
  • 28
  • 32
  • 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 '12 at 05:56
  • 1
    And remember to clear the Err object after a problem, if you want to carry on and check it again later! – Magnus Smith Jun 26 '14 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
El Bandito
  • 31
  • 1
  • It usually ends up without data for some reason – JNF May 20 '13 at 09: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 07 '14 at 14:54