justCF

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.)
Russ S.'s Gravatar 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
lex's Gravatar +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
Mike Collins's Gravatar 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
BlogCFC was created by Raymond Camden. This blog is running version 5.9.5.004.