Error checking with ASP classic VbScript

Here is a handy snippet for those rare occasions when you bother to error check.

 

If Err.Number <> 0 Then
subject = "Error creating early alert"
email_message = "There was the following error while creating an early alert record: " & Err.Number & " : " & Err.Description
sendEmail adminEmail, email_message, from_email, subject
End If

Can deliver a helpful error message such as:

There was the following error while creating a record: -2147217900 : Unclosed quotation mark after the character string ‘Failed a quiz/test’.

Leave a Reply