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 (Comment Moderation is enabled. Your comment will not appear until approved.)
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
sell my laptop's Gravatar Find out how much you could earn for your old laptop with Cash in your Gadgets.
# Posted By sell my laptop | 01/09/15 23:56
wholesale digital cameras's Gravatar Stock Sourcing provide a regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
# Posted By wholesale digital cameras | 10/09/15 00:25
gadgetdrive.co.uk's Gravatar GadgetDrive allows schools, clubs and good causes to accept donations in the form of electronic gadgets including mobile phones, digital cameras, tablet PCs and laptops, which are then turned into a real cash by Gadgetdrive.
# Posted By gadgetdrive.co.uk | 10/09/15 00:26
Fat Reduction Surgery's Gravatar I like the global error handling feature of this framework. Nice and simple to implement. Thanks.
# Posted By Fat Reduction Surgery | 03/10/15 06:58
apartment'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 apartment | 04/10/15 00:11
cardsharing's Gravatar web development and application builds. I like the global error handling feature of this framework. Nice and simple to implement. Thanks.
# Posted By cardsharing | 05/10/15 06:00
buy traffic's Gravatar I like the global error handling feature of this framework. Nice and simple to implement.
# Posted By buy traffic | 05/10/15 23:18
cccam server's Gravatar Stock Sourcing provide a regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
# Posted By cccam server | 07/10/15 05:46
Marketing dashboard's Gravatar Stock Sourcing provide a regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
# Posted By Marketing dashboard | 07/10/15 06:24
cardsharing's Gravatar naf dinsdagavond is er kans op regen- of onweersbuien.
# Posted By cardsharing | 08/10/15 06:03
gurgaon to jaipur cab's Gravatar Afonso III serves up some of the most traditional Macanese dishes.
# Posted By gurgaon to jaipur cab | 11/10/15 01:59
buy visitors's Gravatar That’s asking a lot of my audience, so thank you to those of you who picked it up!
# Posted By buy visitors | 20/10/15 07:31
Bulk buy Twitter accounts's Gravatar regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
# Posted By Bulk buy Twitter accounts | 21/11/15 00:54
Quality Plumbing's Gravatar FW/1 looks for and uses an error handling template.
# Posted By Quality Plumbing | 22/11/15 00:36
facebook likes's Gravatar Your website is really cool and this is a great inspiring article. Thank you so much.
# Posted By facebook likes | 14/12/15 23:45
youtube views's Gravatar Thanks for sharing the info, keep up the good work going.... I really enjoyed exploring your site. good resource...
# Posted By youtube views | 14/12/15 23:47
hacker clash of clans . subway surfers unlimited c's Gravatar Stock Sourcing provide a regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
salmanonline's Gravatar Great Tutorial. It was worth reading. Thanks for your effort in taking some time to share this post on the forum. You can get some more great content here. http://directtutorials.com/salman-khan-hd-wallpape...
# Posted By salmanonline | 15/12/15 15:08
harry's Gravatar Using this framework for the most smaller scale projects is going to benefit most of the outputs. I would like to make a try with this to my ongoing project http://www.topessaywriting-services.com/and would like to view the results here.
# Posted By harry | 16/12/15 03:26
buy youtube subscribers ! buy twitter followers's Gravatar Stock Sourcing provide a regular and reliable source of wholesale used laptops, mobile phones, TVs, computers and digital cameras at low prices.
Back to top