Classic ASP: On Error Stop
asp-classic, error-handling
Solution
If you want it to throw an error without going to any sort of custom error handler, use:
On Error GoTo 0
You can test it out in a quick sample ASP page with the following:
<% Language="VBScript" %>
<% Response.Write "Hello" %>
<% On Error Resume Next
Dim rs
SET rs = Server.CreateObject("ADODB.RecordSet")
'On Error Goto 0
rs.MoveNext
%>
<% Response.Write "Bye" %>
With `On Error Goto 0` commented out, `Bye` will get written as normal. With `On Error Goto 0` enabled, you'll get the following error:
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
Problem
I have an ASP page that runs two SQL insert statements at the beginning before displaying the page. In the event I get a primary key conflict (ie. the inserts have already ran that day), I just want to carry on. My code is basically: ``` on error resume next ' insert statements ``` Once the statements have been executed, I would like to resume the default error behaviour, where the page dies with an error message. Is there a command, like "on error stop", or "on error die", or "on error default", or something to reset the error handling to it's default behaviour?