[Catalyst] Catching errors in end
Bill Moseley
moseley at hank.org
Sat Dec 10 17:13:39 CET 2005
I suspect I'm trying to do this the had way. I want to handle errors
and display my own error template.
sub end : Global {
my ($self, $c) = @_;
return if $c->res->status == 304;
if ( @{$c->error} ) {
$c->log->error($_) for @{$c->error};
$c->res->status( 500 );
$c->error(0);
}
$c->stash->{template} = 'error.tt' unless $c->res->status == 200;
$c->forward('App::V::TT') unless $c->res->body;
}
But that doesn't work if the error happens in the template, so after
calling TT I added:
# Catch errors in the template
if ( @{$c->error} ) {
$c->res->status( 500 );
$c->error(0);
$c->stash->{template} = 'error.tt';
$c->forward('App::V::TT');
}
}
Which seems a bit redundant. Is there a better (single) place to
catch both those? Override finalize_error instead? Or maybe just a
better approach?
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list