Keeping on top of website errors

One of my favorite books depicts a southern farmer who boasts how his animals do all the work (maintaining the grass by eating it, etc, etc.) Wouldn't it be great if we, as web programmers, could let our users do the testing?

This dream scenario, of course, works best on public beta sites, but it has application on live/production websites as well.

The concept here is called a Global Error Handler. Some languages support it natively. For others, you'll have to include it in a global include file of some kind.

Essentially, this error handler either stores user-generated errors to database, or emails the information to your development team. I prefer the latter, as it forces you to keep tabs on the errors.

ColdFusion offer's "native" support for this via it's Application.cfc onError function. An example below demonstrates how to include relevant error information in your email:

<cffunction name="onError" returnType="void" output="true">
    <cfargument name="Exception" required="true">
    <cfargument name="EventName" type="string" required="true">

            <h2>An unexpected error occurred.</h2>
            <p>Please provide the following information to technical support:</p>
            <p>Error Event: #Arguments.EventName#</p>
            <p>Error details:<br>
            <cfdump var="#Arguments.Exception#"></p>
            <cfsavecontent variable="mail_html">
                Redirect URL: <cfoutput>#CGI.REDIRECT_URL#</cfoutput>
                <cfdump var="#Arguments.Exception#">       
                <cfdump var="#CGI#">

       <cfmail ... type="text/html">


Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs

Tagged .

Updated: 2012-04-19

Phil LaNasa follow us in feedly