Blog

ColdBox 4.0 Error Handling

Brad Wood January 29, 2015

Spread the word

Brad Wood

January 29, 2015

Spread the word


Share your thoughts

ColdBox has always provided nice, automatic error handling for your code.  Errors in your application are caught for you, and you can respond to them via convention-based methods, event handlers, or even interception points as you see fit.  (Read more on ColdBox error handling here)

If you do nothing, ColdBox will render a nicely formatted page with all the original exception information plus extra details about the ColdBox request which can be handy for debugging.  Due to our focus on security-by-default in ColdBox 4, we found that a large  number of people never change the default error template and their production servers give out way too much information!  Even though having a 'detailed' template by default was convenient, it wasn't secure.  

Therefore, we now ship ColdBox with two error templates.  (Of course you are still encouraged to make your own custom ones.)

  • BugReport.cfm
  • BugReport-Public.cfm

Get Your Info Back

BugReport-Public is what is enabled by default.  It outputs very little information so the baddies can't use your default error template as an attack vector to gather information about your server.  Don't worry though, the original error template (BugReport) is still there and can easily be enabled at any time. 

To get your old error template back, simply add the customErrorTemplate setting in your /config/ColdBox.cfc like so:

coldbox = {
	customErrorTemplate = "/coldbox/system/includes/BugReport.cfm"
};

Note: you can point to any valid .cfm file with this setting.  Feel free to create your own themed error template that matches your site's layout.  Just remember, this is not a view-- just a stand-alone .cfm file that can only access the variables.exception object.

An Even Better Way

We don't recommend just changing the setting like that because you're likely to forget and put yourself back at square 1 again when you push your code to production.  What's best is to leave the production error template to a 'secure' one and add a development override that only uses the public template on your development servers.  

coldbox = {
	customErrorTemplate = "/includes/myCustomPrettyErrorPage.cfm"
};

environments = {
	development = "localhost"
};

function development(){
	coldbox.customErrorTemplate = "/coldbox/system/includes/BugReport.cfm";
};

Now, your default production setting is your custom pretty error page, but on your dev server you get the juicy details.  Make sure you've also configured some LogBox logging on production so you have some way to get your error messages!

Read more about ColdBox 4 compatibility here:

http://wiki.coldbox.org/wiki/Compatibility:4.0.0.cfm

Install ColdBox 4.0 with CommandBox today with this simple command:

CommandBox> install coldbox

Add Your Comment

Recent Entries

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023