Sep 13, 2016

Simple way to capture your CFCatch structure

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.
<cfinclude template="asdfasdf.cfm">
<cfcatch type="any">
<cfdocument filename="errorreport#gettickcount()#.pdf" format="pdf">
    ColdFusion Error<br />
    <cfdump var="#cfcatch#">
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.

Use this technique for troubleshooting purposes,  you would not want to start to create hundreds or thousands of documents over a short period of time.

No comments:

Post a Comment