CFERROR ColdFusion Error Template Will Not Catch Its Own Errors

Posted June 28, 2006 at 5:03 PM

Tags: ColdFusion

This guy at work could not figure out why some errors in his application were being caught by his error handling template (as defined by the CFError tag) and some were not. The errors being caught were handled nicely. The ones that were seemingly not caught were dumped out on to the page as if no error handler was defined.

This is a common problem that I see with people's error handling template. The problem here is that the CFError template will NOT handle errors that it produces. If this were the case, it could launch into some crazy, infinite loop of error handling. By surrounding the code of the error handling template with CFTry / CFCatch tags, it became immediately apparent that his error handler had a bug in it.

Post Comment  |  Ask Ben  |  Permalink  |  Print Page


You Might Also Be Interested In:



Learning ColdFusion 9 - ColdFusion 9 tutorials, samples, examples, demos

Reader Comments

Jun 3, 2008 at 9:03 AM // reply »
1 Comments

my url is http://localhost/cftest/index.cfm if i made a mistake in index.cfm file, cferror tag does not catch it.
but if i include any other file in index.cfm file and make a mistake in included file , the cferror tag works fine
why is this?


Jun 3, 2008 at 9:18 AM // reply »
6,516 Comments

@Faaiq,

There probably is something wrong in the error handler. Try cfdumping out CFERROR in the beginning and aborting.


Aug 25, 2008 at 1:41 PM // reply »
11 Comments

You may have some type of syntax cvalidation error,
which I am noticing cfError will not handle.

if your error is in an included file, then the include validate fails and it falls under "fail to include x file" and becomes a different type of error.


Post Comment  |  Ask Ben

Recent Blog Comments
Nov 20, 2009 at 11:32 PM
Five Months Without Hungarian Notation And I'm Loving It
I've used headless camel case for years for not only ColdFusion variables, but also SQL tables and fields... pretty much everything involving code. I also subscribe to the "don't abbreviate and clea ... read »
Nov 20, 2009 at 11:00 PM
Five Months Without Hungarian Notation And I'm Loving It
@Marcel, Yeah, I always err on the side of longer but more readable variable names. As for the camel casing of CF methods and the headless camel casing of custom items, I get around this by always ... read »
Nov 20, 2009 at 10:56 PM
Five Months Without Hungarian Notation And I'm Loving It
I use the following and love it: my.namespace.MyComponents.functionMethodsOrUDF() CONSTANT_VALUES_OR_PROPERTIES One thing I always try is to CamelCaseBuiltInColdFusionFunctions() so others can tell ... read »
Nov 20, 2009 at 5:38 PM
Learning ColdFusion 8: CFImage Part I - Reading And Writing Images
Hi Ben, Great article. I've been looking around to see if ColdFusion image engine can programatically create the following "wrap around" effect: http://www.creativepro.com/article/photoshop-s-she ... read »
Nov 20, 2009 at 5:35 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Dave: I talked to Gert he suggested: <cfhttp method="get" url="http://{some cf website}" result="stuff" addtoken="yes" /> Note the addition of cfhttp attribute addtoken. That should persist y ... read »
Nov 20, 2009 at 5:23 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
@Todd, Ahh, gotcha, yeah that makes sense. ... read »
Nov 20, 2009 at 5:17 PM
Maintaining ColdFusion Sessions Across SMS Text Message Requests Without Cookies
Ben, sorry if I didn't make this clear. You can make it work like that if you want, just put <cfset session.foo = 1> (and <cfset application.foo = 1>) in your OnRequestStart() and it reve ... read »