[Catalyst] Custom error
Jason Kohles
email at jasonkohles.com
Tue Jun 26 17:01:11 GMT 2007
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 {
my ( $self, $c ) = @_;
$c->forward( 'render' );
if ( my @errors = @{ $c->errors } ) {
$c->response->content_type( 'text/html' );
$c->response->status( 500 );
$c->response->body( qq{
<html>
<head>
<title>Error!</title>
</head>
<body>
<h1>Oh no! An Error!</h1>
} . ( map { "<p>$_</p>" } @errors ) . qq{
</body>
</html>
} );
}
}
>
>> I think what Evaldas means is that an error (template not found, etc)
>> in the View rendering stage will not be caught by the method in the
>> Cookbook.
>>
>> I am away from my code at the moment, but IIRC the trick is to check
>> $c->error AFTER you forward to MyApp::V::TT (or after the RenderView
>> action) and then setup your error.tt template and forward to the view
>> again.
>>
>> If that doesn't make sense I can provide a code example later.
>
> --
> -----------------------------------------------------
> Evaldas Imbrasas
> http://www.imbrasas.com
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/
> catalyst at lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
--
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing." -- Voltaire
More information about the Catalyst
mailing list