SupportObjective
ColdFusion Consulting, Support and Sales

Often times we get cases where we need the complete stack trace of an error and not what is reported by any custom error handler template.

Here is a great way to track your errors that also allows inspection of the entire cfcatch structure at a later time, without interfering with any custom templates.

view plain print about
1<cftry>
2    <cfinclude template="asdfasdf.cfm">
3<cfcatch type="any">
4<cfdocument filename="errorreport#gettickcount()#.pdf" format="pdf">
5 ColdFusion Error<br />
6 <cfdump var="#cfcatch#">
7</cfdocument>
8</cfcatch>
9</cftry>

In the above code I create a missing template exception, then have the cfcatch simply use cfdocument with a unique filename, to dump out the cfcatch to a PDF file.

You can adjust the location etc as you see fit of course.

The result is a PDF for every occurence showing the complete error and hopefully allowing you to quickly get to a resoluiton.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
I'd be weary of creating a new PDF for every error. Imagine the worst-case scenario: A malicious hacker sets up a script that causes errors on your site. Not only will this hang up your server's CPU trying to generate a PDF for each error, but eventually you'll run out of disk space and the server will crash.

Logs are simple text files for a reason!
# Posted By Russ S. | 5/6/11 9:15 PM
+1 Russ. I would also add that cfdump can now output to a file in text or html format.
# Posted By lex | 5/7/11 9:30 AM
Good points. A simpler approach would be use text and or cfdump to a file.

The file approach was something that makes it easy to email specific errors

Thanks for your feedback.
# Posted By Mike Collins | 5/7/11 12:11 PM