Hi,

I have a cferror type = "exception" exception="any" in my application.cfm file. This works great for most errors, but I recently found that it is not working for attribute validation errors.

For example, if I misspell an attribute for the cfqueryparam tag, my custom error page is not called. Instead, I get the default error that shows the SQL in my query, which I don't want. Cftry/cfcatch didn't work, either.

I can't use the Site-wide Error Handler, because I'm on a hosted server and I'm not allowed to make any changes to the Coldfusion Administrator.

Any ideas?

Thank you.

Instead, I get the default error that shows the SQL in my query, which I don't want. Cftry/cfcatch didn't work, either.

There are two different types of errors that can occur in a webpage: parsing / compile-time errors and run-time errors. If you misspell an attribute in the query, then the cf engine can already determine that the query is not going to work, so it doesn't try to execute the query and then die with an exception that the attribute was misspelled. It checks that ahead of time when it is parsing / compiling the page.

This works great for most errors, but I recently found that it is not working for attribute validation errors.

You must fix those types of errors at compile-time, i.e., try to compile all of your web pages and see what errors arise. Or at least view all of your pages once first before you publish them for the whole world to see, and you can catch those errors, because the error will show up every time the page is viewed, not just sometimes, if the error is a compile-time error. A run-time error only shows up in the situation that causes the exception, and it makes sense to catch those errors gracefully.

~ mellamokb

More information can be found at:

http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000242.htm

DracTK said on Apr 12, 2007 at 9:11 AM :
What thekat is saying is that the CF template has to be compilable in order for errors that cferror can catch to occur. cferror is only for run time errors, doesn't work for compile time errors (which makes a lot of sense).
Runrocket said on Jul 9, 2007 at 8:12 AM :
What is interesting is that while CFERROR will not catch compile time errors like '<cfet x = 1 />', if you define a site wide error handler in CF Administrator, this error will get caught and the user will be redirected to your custom error template. The problem here is that this error template cannot be customized for a specific application, but will appear for all applications hosted on your stand alone server or JRun instance.

~ mellamokb

Thank you, mellamokb. That was helpful. I just wanted to make sure I was doing everything possible. I do always check before I publish a page, but I've inherited this site, and there are a lot of pages that I haven't worked on.

Thanks again!

-- Lafalot

No problem. Glad to help!

~ mellamokb

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.