Monday, June 18, 2007

Classic ASP Error Handling

On Error Resume Next
'this will cause the page to continue processing when it hits an error
 
'after all scripting
If Err.number <> 0 then
    Dim msg msg = "Error Number " & Err.number & " occurred in millionDollarRequest.asp. Description: " & Err.Description & " SOURCE: " & Err.Source
    msg = msg & " IPADDRESS: " & Request.ServerVariables("REMOTE_HOST")
    sendEmailError(msg)
    Err.Clear
end if
 
'typical error message mailer
function sendEmailError(msg)
 Dim Mailer
 Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
 Mailer.RemoteHost  = "mail.XXXXXX.com"
 Mailer.Timeout = 30
 Mailer.FromName = "ERROR REPORT"
 Mailer.FromAddress = "webmaster@XXXXXXXXX.com"
 Mailer.ReplyTo = "webmaster@XXXXXXX.com"
 Mailer.AddRecipient "", "YYYYYYY@XXXXXXXXX.com"
 Mailer.Subject = "ERROR Alert"
 Mailer.BodyText = msg
  
 sendEmail = Mailer.SendMail
end function
 
 
 

Labels: ,

Tuesday, June 12, 2007

Reqular Expressions and SQL

FIND: ^\(.+\)$
REPLACE: \0 = formToSql("\0")

Labels: ,