|
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.