CFMX Error Template

Here are a few things I found out about the way the error template works in CFMX which I posted to a couple of CF Mailing lists on 12/20/2002.

Just thought I’d pass along an interesting difference I found in CFMX today with error templates since I finally have it in a production setting. Its probably already been covered somewhere, but it can’t hurt to share.

If multihoming on a server, you will want to create a virtual directory in the CF Administrator to somewhere that your error templates are located. Otherwise they will not work as you would expect them to. If your error template depends on anything from a <cfapplication> tag or something else such as that in Application.cfm/OnRequestEnd.cfm AND the error handler is not in the same directory as those files, you’ll need to <cfinclude> them manually. They are not ran during the error handler request if they reside in a different directory (such as if they further up the directory tree.. normally they would be ran). Be sure to wrap the include(s) in <cftry><cfcatch> tags (obviously).

Secondly, if a page cannot be compiled because of something like a syntax error, it will not use the error template and will dump a regular error message to anyone who hits that page. So if you’re depending on some sort of mechanism in your error template to log/report errors, please make sure to check the application log for errors in pages that can’t be compiled (of course you should already be checking it anyhow…).

Hopefully someone will find this useful.

This entry was posted in Languages, Servers, Tips, Hacks, & Tricks and tagged , , , , , , , , . Bookmark the permalink.

Leave a reply