[Catalyst] Custom error

Brian Kirkbride brian.kirkbride at deeperbydesign.com
Wed Jun 27 16:51:53 GMT 2007


Jason Kohles wrote:
> 
> On Jun 26, 2007, at 12:45 PM, Brian Kirkbride wrote:
> 
>> Jason Kohles wrote:
>>> On Jun 25, 2007, at 1:27 PM, Evaldas Imbrasas wrote:
>>>> Yes, that's what I meant, thanks Brian. Please provide a code example
>>>> using RenderView action. I think it would also make sense to
>>>> incorporate that example into the Catalyst cookbook instead of
>>>> existing one since that one's incomplete.
>>> Something like this...
>>> sub render : ActionClass('RenderView') { }
>>> sub end : Private {
>>
>> Or even this:
>>
>> sub render : ActionClass('RenderView') {}
>> sub end : Private {
>>   my ($self,$c) = @_;
>>   $c->forward('render');
>>   if (my @errors = @{$c->errors}) {
>>     $c->errors(0);
>>     $c->stash->{template} = 'error.tt';
>>     $c->stash->{errors} = \@errors;
>>     $c->forward($c->view('TT'));
>>   }
>> }
>>
>> To allow for a templated error page.
>>
> The original question was how to deal with the view failing.  If your 
> view is
> broken, you probably don't want to try and use it to render the error...
> 

If the error in the View is that the template was not found, or that 
it had a syntax error, you can render a templatized error page with no 
problem.

Point taken though, the proper solution is probably to try the View's 
error page, catch any errors and fallback to your original solution.

Best,
Brian



More information about the Catalyst mailing list