reusing layouts in onerror() and onmissingtemplate()

56 views
Skip to first unread message

m...@iamjamesgibson.com

unread,
Oct 28, 2009, 8:16:15 AM10/28/09
to ColdFusion on Wheels
Hey Guys,

I would like to be able to reuse my layouts in the onerror() and
onmissingtemplate() methods. I have been trying to figure out a best
way to do this but my attempts so far have failed. Doing something
like this:

<cfset renderPage("/exceptions/internalservererror") />

results in an error since the onError() method is called within the
application scope.

Any ideas?

Thanks,
James

m...@iamjamesgibson.com

unread,
Oct 28, 2009, 10:26:44 AM10/28/09
to ColdFusion on Wheels
It would seem that I have solved my own issue :)

I am able to use the following code in /events/onerror.cfm and /events/
onmissingtemplate.cfm to basically re-run the request with new
pathinfo.

<cfscript>
request.cgi.path_info = "/exceptions/internalservererror";

StructDelete(url, "action");
StructDelete(url, "controller");
StructDelete(url, "route");

WriteOutput(application.wheels.dispatch.$request());
</cfscript>

I just changed out the path_info for each event. This seems like a
good solution as you could test for different types of errors in
onerror and return the proper exception action. This method has the
additional benefit that if an error occurs within onerror(),
Coldfusion catches it and shows the standard coldfusion error display
(no recusive error trapping). Also, the status headers wheels set (404
for onmissingtemplate and 500 for onerror) still show up for the
request.

Maybe I should make this a plugin.

James

On Oct 28, 8:16 am, "m...@iamjamesgibson.com"

m...@iamjamesgibson.com

unread,
Oct 28, 2009, 11:17:32 AM10/28/09
to ColdFusion on Wheels

Per Djurner

unread,
Oct 28, 2009, 12:00:02 PM10/28/09
to cfwh...@googlegroups.com
Great plugin!
I can definitely see this being added directly in Wheels too (since it
seems like it should have been there from the start...).
Don't forget to upload the plugin to the site as well.

m...@iamjamesgibson.com

unread,
Oct 28, 2009, 2:30:05 PM10/28/09
to ColdFusion on Wheels
Hey Per,

Just thinking out loud here, but maybe wheels should come prepackaged
with an Exceptions.cfc controller that contains the following methods:

- notFound (404 error)
- notAcceptable (406 error, this method might need to come later when
wheels internals respond to different request types)
- internalServerError (500 error)
- downForMaintenance

Then wheels can come pre-packaged with these pages rendering for their
particular events.

Just a thought.

James

On Oct 28, 12:00 pm, Per Djurner <per.djur...@gmail.com> wrote:
> Great plugin!
> I can definitely see this being added directly in Wheels too (since it
> seems like it should have been there from the start...).
> Don't forget to upload the plugin to the site as well.
>
> On Wed, Oct 28, 2009 at 4:17 PM, m...@iamjamesgibson.com
>
> <m...@iamjamesgibson.com> wrote:
>
> > You can check out the plugin at the link below.
>
> >http://github.com/liferealized/exceptionRender
>
> > or download it at
>
> >http://github.com/liferealized/exceptionRender/raw/master/releases/Ex...

raulriera

unread,
Oct 28, 2009, 2:59:41 PM10/28/09
to ColdFusion on Wheels
I like that controller idea... that way helpers will be available as
well I assume?

On Oct 28, 2:30 pm, "m...@iamjamesgibson.com"

m...@iamjamesgibson.com

unread,
Oct 28, 2009, 3:03:56 PM10/28/09
to ColdFusion on Wheels
The full wheels life cycle for a request is basically replayed.

James

tpet...@gmail.com

unread,
Oct 29, 2009, 4:56:28 PM10/29/09
to ColdFusion on Wheels
this really is an excellent idea james. we should put this on the
slate for 1.1

On Oct 28, 3:03 pm, "m...@iamjamesgibson.com"

funaroma

unread,
May 6, 2018, 10:37:53 AM5/6/18
to CFWheels
This was ages ago, but would like to know what ever became of the idea of adding exception handling to cfwheels, so that it's easier to wrap the onError / onMissingTemplate /etc messages in a site's layout?

Tom King

unread,
May 6, 2018, 11:08:53 AM5/6/18
to cfwh...@googlegroups.com
Well, there's this:

Which is probably the most up to date version of Jame's plugin

T
Reply all
Reply to author
Forward
0 new messages