Error Handling in ASPPY
On Error Resume Next, Err object, and defensive patterns
On Error Resume Next
When enabled, execution continues after errors. Use Err.Number to check.
Err.Number: 11
Err.Description: Division by zero
Err.Source: Microsoft VBScript runtime error
Err.Description: Division by zero
Err.Source: Microsoft VBScript runtime error
The division by zero was caught and handled gracefully. Without On Error Resume Next, it would crash the page.
Type Mismatch Example
Mismatched types raise error 13.
Error 13: Type mismatch
Trying to add a string and integer without
Trying to add a string and integer without
& causes a type mismatch.
Database Error Pattern
Safe DB query pattern using On Error Resume Next.
DB Error 438: Object doesn't support this property or method: Unknown member: EXECUTE on _Sentinel
Query attempted on a table that doesn't exist. The error was caught and the page continues.
Query attempted on a table that doesn't exist. The error was caught and the page continues.
Safe Error Handler
A reusable pattern for any operation.
Last error caught: 13 - Type mismatch
Trigger an Error
Use Err.Raise to generate custom errors for testing.
Raised Error 424: This is a test error raised by Err.Raise
Source: Demo
Source: Demo
Key Learning
- Always use
On Error Resume Nextbefore risky operations - Check
Err.Number <> 0immediately after - Call
Err.Clearafter handling to reset state On Error GoTo 0is not supported in ASPPY — useErr.ClearinsteadvbCrLfand underscore line continuation work normally