Handling Errors in ASP

The Err object is extremely handy because even if we tell the script to keep executing after an error, the Err object will keep track of the fact that the error occurred. It will also provide us with information about the error. In Listing 8.34, we add error checking to order_complete_action.asp.

Code Listing 8.34. order_complete_action.asp: Adding error checking
0: <%@ LANGUAGE="VBSCRIPT" %>
1: <!--#include file="adovbs.inc"-->
2: <!--#include file="pagetop.txt"-->
3: <!--#include file="isadmin.inc"-->
4: <%
5:    sub sub_ArchiveOrder (s_order_id, s_status)
…
52:           orderItemSet.MoveNext
53:        wend
54:
55:        orderItemSet.filter = 0
56:
57:        if Err.Number = 0 then
58:            'There were no errors
59:            Response.Write "Order number " & p_order_id ...

Get Active Server Pages 3.0 from Scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.