<% Function errHandler(strErrNumber,strErrSource,strErrDescription,strDSN,blnRedirect) Dim i, blnDebug Dim objConn, objCMD, intReturn, strIPAddress, strPath, strTo, strBody, arrErrNumber, strHTTP_REFERER blnDebug = FALSE strTo = "" strBody = "" strIPAddress = Left(Trim(Request.ServerVariables("LOCAL_ADDR")),16) strPath = (Trim(Request.ServerVariables("SERVER_NAME")) & Trim(Request.ServerVariables("SCRIPT_NAME"))) strHTTP_REFERER = Request.ServerVariables("HTTP_REFERER") 'Err.Clear On Error Resume Next Set objConn = Server.CreateObject("ADODB.Connection") Set objCMD = Server.CreateObject("ADODB.Command") objConn.Open "DB_ERRORS", "dberror", "dberror" If blnDebug = TRUE Then response.write "

1) strErrNumber: " & strErrNumber response.write "

2) strErrSource: " & strErrSource response.write "

3) strErrDescription: " & strErrDescription response.write "

4) strDSN: " & strDSN response.write "

5) blnRedirect: " & blnRedirect 'response.end End If objCMD.ActiveConnection = objConn objCMD.CommandType = 4 objCMD.CommandText = "sp_insert_error" objCMD.Parameters(1) = Now() objCMD.Parameters(2) = Left(strIPAddress,16) objCMD.Parameters(3) = Left(strErrNumber,50) objCMD.Parameters(4) = Left(strErrSource,100) objCMD.Parameters(5) = Left(strErrDescription,255) objCMD.Parameters(6) = Left(strPath,255) objCMD.Parameters(7) = Left(strDSN,50) If blnDebug = TRUE Then response.write "

1: " & objCMD.Parameters(1).Value response.write "
2: " & objCMD.Parameters(2).Value response.write "
3: " & objCMD.Parameters(3).Value response.write "
4: " & objCMD.Parameters(4).Value response.write "
5: " & objCMD.Parameters(5).Value response.write "
6: " & objCMD.Parameters(6).Value response.write "
7: " & objCMD.Parameters(7).Value End If If blnDebug = TRUE Then response.write "

just before execute..." objCMD.Execute intReturn = objCMD.Parameters("RETURN_VALUE").Value If blnDebug = TRUE Then response.write "

errHandler intReturn: " & intReturn response.write "
after execute err.description: " & Err.Description End If Select Case intReturn Case 0 'expected return if stored proc ran successfully, so check whether or not the email alert should be sent Set objCMD = Nothing Set objCMD = Server.CreateObject("ADODB.Command") objCMD.ActiveConnection = objConn objCMD.CommandType = 4 objCMD.CommandText = "sp_insert_error_email" 'check error count for this error and today's date objCMD.Parameters(1) = strIPAddress objCMD.Parameters(2) = Date() objCMD.Parameters(3) = strErrNumber objCMD.Execute intReturn = objCMD.Parameters("RETURN_VALUE").Value If blnDebug = TRUE Then Response.Write "

Case 0 intReturn: " & intReturn Response.Write "

Case 0 err: " & Err.Description End If If intReturn = 1 Then strTo = "schan@mcafee.com" 'check whether or not IT should receive the email based on the error number 'put the following lines back to add error code-based recipients 'arrErrNumber = Array("-2147467259","-2147217843") 'i = 0 'For i = 0 To UBound(arrErrNumber) 'If Trim(strErrNumber) = arrErrNumber(i) Then 'strTo = strTo & ";nubyte@ix.netcom.com" 'End If 'Next strBody = "DB Failure On Server: " & Trim(Request.ServerVariables("SERVER_NAME")) & " - " &_ strIPAddress & vbCrLf & vbCrLf & "DSN NAME: " & strDSN & vbCrLf & vbCrLf &_ "ASP Page: " & strPath & vbCrLf & vbCrLf If InStr(1,strPath,"popupad.asp") > 0 Or InStr(1,strPath,"redir.asp") > 0 Then strBody = strBody & "Query String: ?" & Request.ServerVariables("QUERY_STRING") & vbCrLf & vbCrLf End If strBody = strBody & "HTTP REFERER: " & strHTTP_REFERER & vbCrLf & vbCrLf &_ "Error Source: " & strErrSource & vbCrLf & vbCrLf &_ "Error Number: " & strErrNumber & vbCrLf & vbCrLf &_ "Error Description:" & vbCrLf & strErrDescription & vbCrLf & vbCrLf & "Time: " & Now() End If Set objCMD = Nothing Case -1 'the initial select statement failed inside the stored proc strTo = "schan@mcafee.com" strBody = vbCrLf & "Stored Proc, sp_insert_error, is failing on WEBMONITOR" & vbCrLf Case Else strTo = "schan@mcafee.com" strBody = "stored proc, sp_insert_error, in the errors table on WEBMONITOR returned the following unexpected message..." &_ vbCrLf & vbCrLf & "intReturn: " & intReturn & vbCrLf & vbCrLf & "Extended Information:" & vbCrLf & Err.Description End Select If blnDebug = TRUE Then Response.Write "

strTo: " & strTo & "

strBody: " & "
" & strBody End If If strTo > "" Then Dim objMail Err.Clear On Error Resume Next Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.Importance = 2 objMail.From = "db_error@mcafee.com" objMail.To = strTo 'If blnDebug = FALSE Then 'If InStr(1,strHTTP_REFERER,"upgradeList3.asp") > 0 Then 'objMail.CC = "sandy_parish@mcafee.com;dean_burrill@mcafee.com" 'End If 'End If objMail.Subject = "McAfee.com Database Failure" objMail.Body = strBody objMail.Send Set objMail = Nothing End If If IsObject(objCMD) Then Set objCMD = Nothing objConn.Close If blnDebug = TRUE Then Response.End 'send client to error page for graceful message if blnRedirect is TRUE If blnRedirect = TRUE Then Response.Redirect "http://" & WWW_MCAFEE_COM & "/error.asp" End Function %>