Blog

Brad Wood

August 09, 2012

Spread the word


Share your thoughts

 

ColdBox gives you several ways to deal with unhandled exceptions in your application such as the exceptionHandler event and the onException interception point to name a couple.  With either of those approaches, you can redirect the request to a different event.  If you don't redirect or abort the request though, ColdBox will eventually display the contents of your error template.  
 
By default the error template is /coldbox/system/includes/BugReport.cfm.  This file has the familiar "Oops! Exception Encountered" header.  While BugReport.cfm is chock-full of juicy error details (including the SQL of queries that errored), it isn't the kind of information you want to be revealing to the general public.  
 
This is where your customErrorTemplate setting from the ColdBox config file comes in.  Set this to the path of the page you want your users to see when something goes wrong on the site.  
 
settings.customErrorTemplate = "/includes/sorry.cfm";
 
You'll probably want to display a comforting message, a link to your webmaster's E-mail address, or your customer service number.  If you're feeling cheeky, you could try an octocat, or fail whale.  :)  Remember, your custom error template is NOT a view.  It won't be rendered inside your site layout and it won't have access to variables a view normally gets, but it will have an exceptionBean object passed in.  You can go digging for what you need with getController(), but 1be careful-- you don't know what kind of state the framework is in.  If you create an error on this page, it will bubble up to the onError method in your application.cfc.
 
 
P.S. This is an excellent place to use environment overrides to use the default error page on your dev and staging server, but the pretty one on production.  Just set the path to the pretty page in your main settings block, and override it with an empty string (which means use the default) in your lower environment overrides.

Add Your Comment

(1)

Oct 10, 2013 17:22:57 UTC

by Tim Brown

What if i just want to return the execption information as JSON so it can be gracefully displayed via my client side code?

It doesn't appear I can stop execution within the onException() handler using renderData().noExecution() as renderData is ignored (as stated in the docs). Do I just need to set some headers and return the JSON manually via cfcontent?

Thanks!

Recent Entries

November 2026 Roundup: What’s New Across Ortus Solutions & BoxLang

November 2026 Roundup: What’s New Across Ortus Solutions & BoxLang

From BoxLang 1.19 and BoxLang AI 3.7 to new migration tooling, QA insights, hands-on AI development with students, and community events around the world, this month continued to show how the different parts of our ecosystem connect.

We also officially launched Into the Box 2027 in Orlando and opened our Ortus Year-End Offers, giving teams new ways to start planning their development, modernization, and training goals for the year ahead.

Here’s everything you may have missed in November.

Victor Campos
Victor Campos
December 01, 2026
Is Your CFML Upgrade Overdue? See Where BoxLang and BxLens Can Help

Is Your CFML Upgrade Overdue? See Where BoxLang and BxLens Can Help

An overdue ColdFusion or Lucee upgrade gets easier to scope when you know which workflows could be affected. See how BoxLang helps you assess a migration and how BxLens helps you investigate slow requests and recurring errors.

Maria Jose Herrera
Maria Jose Herrera
November 30, 2026
Announcing bxSites 1.0: Every Site You Run, From One Folder of Markdown

Announcing bxSites 1.0: Every Site You Run, From One Folder of Markdown

Ortus Solutions today announced bxSites 1.0, the first stable release of its free and open source site generator. bxSites turns plain Markdown into documentation, marketing sites, blogs, courses and knowledge bases that load fast, get found, read well for AI, deploy to any host and belong entirely to you.

Luis Majano
Luis Majano
November 30, 2026