Ask a Jedi: Why isn't my cferror working?

This post is more than 2 years old.

Steve asks:

Huge problem I have: custom Error Handling in CF 8 doesn't work whatever I do. I use a simple Application.cfm:

<cferror type="exception" template="ErrorException.cfm" mailto="">

ErrorException.cfm exists and is NOT empty

The template generating the error is index.cfm:

Is there any other setting I have to enable/disable in CF Admin for this to work? I still get the default CF error message, nothing custom.

What you have is a compiler error, or a syntax error. Consider the normal CF execution process. You request index.cfm. CF takes your ColdFusion and compiles it into Java. In your case, you have a syntax error. CF can't run your code at all - therefore - error handling can't handle it at all. The only fix for your template is to remove the syntax error. If you then ran your file and "i" was never defined, you would correctly see your error template run.

If I may be so bold (yes, I'll do), you should check out my guide on error handling:

The Complete Guide to Adding Error Handling to Your ColdFusion Application. It's guaranteed to be more exciting than filing taxes!

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Raul Riera posted on 2/18/2008 at 8:13 PM

And that is a good thing, otherwise you could find yourself debugging that template like MAD

Comment 2 by Aaron Longnion posted on 2/18/2008 at 11:44 PM

Also, note that compile-time errors (such as syntax errors) will be caught by the site-wide Error Handler defined in the CF Admin. And in that site-wide Error Handler CFM template, you have access to the Error scope, as well as CGI, URL, FORM, etc. from the page where the error originally occurred. As Ray has pointed out in some of his posts, when you use this site-wide Error Handler, the 'normal' logging of the error in the logs doesn't take place, so you'll need roll your own and/or email it to yourself.

Again as Ray's pointed out many times, it's essential that you have good, well-thought-out error-handling strategy that handles *all* types of errors. Thanks Ray!

Comment 3 by Jay Pandya posted on 4/4/2011 at 1:15 PM

I am trying to add error handling using type="exception", but it does not work for me.When i am using type="request",it shows good page.Do i need to use any patch or fix etc..

Comment 4 by Raymond Camden posted on 4/4/2011 at 2:59 PM

You need to say _how_ it isn't working for you.