{"id":578,"date":"2012-04-19T21:57:20","date_gmt":"2012-04-19T21:57:20","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=578"},"modified":"2012-04-19T22:00:00","modified_gmt":"2012-04-19T22:00:00","slug":"keeping-top-website-errors","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/keeping-top-website-errors\/","title":{"rendered":"Keeping on top of website errors"},"content":{"rendered":"<p>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&#39;t it be great if we, as web programmers, could let our users do the testing?<\/p>\n<p>This dream scenario, of course, works best on public beta sites, but it has application on live\/production websites as well.<\/p>\n<p>The concept here is called a Global Error Handler. Some languages support it natively. For others, you&#39;ll have to include it in a global include file of some kind.<\/p>\n<p>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.<\/p>\n<p>ColdFusion offer&#39;s &quot;native&quot; support for this via it&#39;s Application.cfc onError function. An example below demonstrates how to include relevant error information in your email:<\/p>\n<p><code>&lt;cffunction name=&quot;onError&quot; returnType=&quot;void&quot; output=&quot;true&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;cfargument name=&quot;Exception&quot; required=&quot;true&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;cfargument name=&quot;EventName&quot; type=&quot;string&quot; required=&quot;true&quot;&gt;<\/code><br \/>\n\t<code><br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;cfoutput&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;h2&gt;An unexpected error occurred.&lt;\/h2&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Please provide the following information to technical support:&lt;\/p&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Error Event: #Arguments.EventName#&lt;\/p&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;p&gt;Error details:&lt;br&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cfdump var=&quot;#Arguments.Exception#&quot;&gt;&lt;\/p&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;cfsavecontent variable=&quot;mail_html&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Redirect URL: &lt;cfoutput&gt;#CGI.REDIRECT_URL#&lt;\/cfoutput&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cfdump var=&quot;#Arguments.Exception#&quot;&gt;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cfdump var=&quot;#CGI#&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;\/cfsavecontent&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/cfoutput&gt;<\/code><\/p>\n<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cfmail ... type=&quot;text\/html&quot;&gt;<\/code><\/p>\n<p>\n\t<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #mail_html#<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/cfmail&gt;<br \/>\n\t&lt;\/cffunction&gt;<br \/>\n\t<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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,&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[34,123,41,4],"tags":[168],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/578"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=578"}],"version-history":[{"count":2,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/578\/revisions"}],"predecessor-version":[{"id":580,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/578\/revisions\/580"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=578"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=578"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=578"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}