[Catalyst] Error handling in Template render
David Schmidt
davewood at gmx.at
Thu Sep 30 06:27:32 GMT 2010
If an exception is thrown it's usually put into the $c->error array.
When this error happens during rendering this doesn't seem to be the
case and I am trying to find out what Catalyst is doing.
In my example forward('render') causes the body to be filled with an
error array.
This is the body after forward('render')
$VAR1 = bless( [
'undef',
bless( {
'msg' =>
'Physio::Schema::Result::Exercises::media(): DBI Exception:
DBD::Pg::st execute failed: ERROR: column me.mediatype does not exist
LINE 1: ..., me.name, me.position, me.file, me.content_type, me.mediaty...
^ [for
Statement "SELECT me.id, me.exercise_id, me.name, me.position,
me.file, me.content_type, me.mediatype, me.created, me.updated FROM
media me WHERE ( me.exercise_id = ? ) ORDER BY position" with
ParamValues: 1=\'1\'] at
/home/david/catalyst/Physio/root/templates/exercises/show.tt line 17
'
}, 'DBIx::Class::Exception' ),
\'
...'
], 'Template::Exception' );
How do I handle this kind of error?
sub end : Private {
my ($self, $c) = @_;
$c->forward('render');
# display catalyst error page
return if $c->debug;
# in production log error and display nice error page
if (@{$c->error}) {
for my $error (@{$c->error}) {
$c->log->error($error);
}
$c->stash(template => 'error.tt');
$c->clear_errors;
}
}
sub render : ActionClass('RenderView') {}
More information about the Catalyst
mailing list