Clean up error handling

This commit is contained in:
Eelco Dolstra 2013-10-03 14:45:23 +02:00
parent 4ddb173ca1
commit c8e5faf81e

View file

@ -223,8 +223,8 @@ sub end : ActionClass('RenderView') {
$c->forward('View::JSON');
}
if (scalar @{$c->error}) {
$c->stash->{resource} = { errors => $c->error };
elsif (scalar @{$c->error}) {
$c->stash->{resource} = { error => join "\n", @{$c->error} };
$c->stash->{template} = 'error.tt';
$c->stash->{errors} = $c->error;
$c->response->status(500) if $c->response->status == 200;
@ -233,17 +233,12 @@ sub end : ActionClass('RenderView') {
$c->response->status . " " . HTTP::Status::status_message($c->response->status);
}
$c->clear_errors;
} elsif (defined $c->stash->{resource} and
(ref $c->stash->{resource} eq ref {}) and
defined $c->stash->{resource}->{error}) {
$c->stash->{template} = 'error.tt';
$c->stash->{httpStatus} =
$c->response->status . " " . HTTP::Status::status_message($c->response->status);
}
$c->forward('serialize') if defined $c->stash->{resource};
}
sub serialize : ActionClass('Serialize') { }