Error Handling in ASP, Part 2

Results 1 to 2 of 2

Thread: Error Handling in ASP, Part 2

  1. #1
    Join Date
    Dec 1969
    Posts
    1,912

    Default Error Handling in ASP, Part 2

    I was looking over the code for the example about Error Handling in ASP, part 2, and I&#039m not sure I see where the ProcessErrors() function is invoked. Maybe I&#039m wrong, but I don&#039t think it&#039s ever called... can anyone clarify this? The code is below:<BR>----------------------------------<BR><BR>&#039code placed after any call to any ADO call<BR>If Err.number &#060;> 0 then<BR> TrapError Err.description<BR>End If<BR><BR>------------- Code for ErrorHandler.asp ------------<BR>&#060;%<BR>Dim strErrorMessage<BR>Dim bolErrors<BR><BR>&#039Initialize variables<BR>strErrorMessage = "" &#039The error messages for tech. support<BR>bolErrors = False &#039Have we found any errors yet?<BR><BR>&#039Now our two subs<BR>sub TrapError(strError)<BR> bolErrors = True &#039Egad, we&#039ve found an error!<BR><BR> strErrorMessage = strErrorMessage & strError & ", "<BR>end sub<BR><BR>&#039If there are any errors, this function will email tech. support<BR>sub ProcessErrors()<BR> if bolErrors then<BR> &#039Send the email<BR> Dim objCDO<BR> Set objCDO = Server.CreateObject("CDONTS.NewMail")<BR><BR> objCDO.To = "techsupport@mysite.com"<BR> objCDO.Subject = "AN ADO ERROR OCCURRED"<BR> objCDO.Body = "At " & Now & " the following errors occurred: " & _<BR> chr(10) & chr(10) & strErrorMessage<BR><BR> objCDO.Send<BR><BR> Set objCDO = Nothing<BR><BR> &#039Now, we&#039ve got to print out something for the user<BR> Response.Write "There has been a database error. Technical Support " & _<BR> "has already been notified. You will be informed when " & _<BR> "this issue is resolved. Thank you for your patience!"<BR> end if<BR>end sub <BR>--- End of ErrorHandler.asp --------------------------<BR><BR>-------- Include statement --------------------<BR>&#060;!--#include virtual="/include/ErrorHandler.asp"--> <BR><BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Error Handling in ASP, Part 2

    Egad, you&#039re right! At the end of your ASP file that includes ErrorHandler.asp, you should put, at the bottom, &#060;% ProcessErrors &#037;&#062;<BR><BR>Thanks for the heads up!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •