What @SearchAndResQ doesn't mention is why your code is failing.
The issue here is Classic ASP will halt execution and return a HTTP 500 Internal Server
to the client (depending on how the server is configured will depend how verbose the response is).
To stop execution halting when an error is encountered or manually raised using Err.Raise()
use On Error Resume Next
. This statement tells the VBScript runtime to jump to the next line when it encounters an error and populate the Err
object.
To then capture this error check the Err.Number
property to see if an error has been raised. Once you have finished use On Error Goto 0
to reset error handling to it's default state (halting execution on error).
If you want to test multiple errors between On Error Resume Next
and On Error Goto 0
inside your error check (If Err.number <> 0 Then
) use Err.Clear()
to reset the Err
object (Err.Number = 0
).
'We are expecting the next statement to sometimes fail so try to trap the error.
On Error Resume Next
' << Statement here you expect to error will be skipped >>
'Check whether error occurred.
If Err.Number <> 0 Then
'An error occurred, handle it here (display message etc).
'Error has been handled reset the Err object.
Call Err.Clear() 'Err.Number is now 0
End If
'Stop trapping errors
On Error Goto 0