Shaun Mccran

My digital playground

08
J
U
N
2011

Handling Error templates in FW/1

I've been using Framework one for a few smaller scale projects, and during a wrap up session I noticed that I didn't have a global catch-all error page, or any kind of error notification subsystem, like an admin email prompt.

This blog article describes how FW/1 looks for and uses an error handling template.

Unlike a lot of open source software FW/1 actually has a pretty decent development guide document. Start off by reading it here: https://github.com/seancorfield/fw1/wiki/Developing-Applications-Manual

The error handling section of the document states that FW/1 will attempt to run 'main.error', if your defaultSection was main, it would look for the file error.cfm.

You can override this in the setup structure in Application.cfc, as per below.

view plain print about
1variables.framework = {
2
3error = 'main.error' // defaultSection & '.error'
4
5// or: defaultSubsystem & subsystemDelimiter & defaultSection & '.error'
6
7};

This works well and makes a lot of sense to me, so now all thats left is to construct an error page.

FW/1 allows you to exempt individual pages from the views layer, but I prefer my error templates to look and work exactly like the rest of the site so I haven't done that.

Dumping all the scopes out in the error page I can see that the url.page variable contains the page I tried to call when the error took place. Also the request scope contains a whole set of data about the error, so I've added a cfdump of that into the cfmail tag.

That way every time the error handler is requested I get an email with the page it tried to call and a dump of the exception message.

view plain print about
1<cfoutput>
2    <cfmail to="" from="" subject="Error" type="html">
3    
4    Admin,<br>
5    
6    This page has broken: #url.page#
7    
8    <cfdump var="#request.exception#" label="Error stack">
9    
10    </cfmail>
11</cfoutput>

Next I'll deal with a global 'page not found' handler within FW/1.

TweetBacks
Comments
Neil Smith's Gravatar I use FW/1 quite a bit for my web development and application builds. I like the global error handling feature of this framework. Nice and simple to implement. Thanks.
# Posted By Neil Smith | 07/04/12 16:27
Back to top