|
Handling Error templates in FW/1 |
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.
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.
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.
![Neil Smith's Gravatar](http://www.gravatar.com/avatar/64e6e7e74c59f637bd430110381b8b47?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![sell my laptop's Gravatar](http://www.gravatar.com/avatar/12c2da42389acfbc4b1e2ba5ba2dc3d9?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![wholesale digital cameras's Gravatar](http://www.gravatar.com/avatar/12c2da42389acfbc4b1e2ba5ba2dc3d9?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![gadgetdrive.co.uk's Gravatar](http://www.gravatar.com/avatar/12c2da42389acfbc4b1e2ba5ba2dc3d9?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![Fat Reduction Surgery's Gravatar](http://www.gravatar.com/avatar/b350ec48ecd4b018a22c190e31458c86?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![apartment's Gravatar](http://www.gravatar.com/avatar/b350ec48ecd4b018a22c190e31458c86?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![cardsharing's Gravatar](http://www.gravatar.com/avatar/43cadeaa4e471e6a5646a5b1b0d14ede?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![buy traffic's Gravatar](http://www.gravatar.com/avatar/f965401f2c5c952025b58a22e376376d?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![cccam server's Gravatar](http://www.gravatar.com/avatar/43cadeaa4e471e6a5646a5b1b0d14ede?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![Marketing dashboard's Gravatar](http://www.gravatar.com/avatar/6a189833f0d4ad4afa19cbc318f55396?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![cardsharing's Gravatar](http://www.gravatar.com/avatar/43cadeaa4e471e6a5646a5b1b0d14ede?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![gurgaon to jaipur cab's Gravatar](http://www.gravatar.com/avatar/f965401f2c5c952025b58a22e376376d?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![buy visitors's Gravatar](http://www.gravatar.com/avatar/6a189833f0d4ad4afa19cbc318f55396?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![Bulk buy Twitter accounts's Gravatar](http://www.gravatar.com/avatar/f965401f2c5c952025b58a22e376376d?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![Quality Plumbing's Gravatar](http://www.gravatar.com/avatar/571d9ffd7e08707d44030be394d40fb9?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![facebook likes's Gravatar](http://www.gravatar.com/avatar/6ff6b2100207608b98a4a9d1cafb1ab2?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![youtube views's Gravatar](http://www.gravatar.com/avatar/6ff6b2100207608b98a4a9d1cafb1ab2?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![hacker clash of clans . subway surfers unlimited c's Gravatar](http://www.gravatar.com/avatar/05cde382ec69c4b4dead03c5b76db63a?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![salmanonline's Gravatar](http://www.gravatar.com/avatar/2c5a6062cf76d6a9b5c896456a7b5e7e?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![harry's Gravatar](http://www.gravatar.com/avatar/87cfd4f062802754e586dfa1a75d8d60?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)
![buy youtube subscribers ! buy twitter followers's Gravatar](http://www.gravatar.com/avatar/05cde382ec69c4b4dead03c5b76db63a?s=40&r=pg&d=http://www.mccran.co.uk/images/gravatar.gif)