my $error = join "\n", @{$c->error};
$c->stash->{response} = { status => 'ERROR', error => $error };
$output = $s->serialize( $c->stash->{response} );
- $c->error(0); # clear errors, so our response isn't clobbered
+ $c->clear_errors;
+ $c->response->status(400);
}
# Serialize the response
};
if ($@) {
my $error = "exception in serialize: $@";
- $c->error($error);
$c->stash->{response} = { status => 'ERROR', error => $error };
$output = $s->serialize( $c->stash->{response} );
+ $c->response->status(400);
}
$c->response->output( $output );
# Forward the request to the appropriate action, based on the
# message type.
my $action = $c->stash->{request}->{type};
- $c->forward($action, [$c->stash->{request}]);
+ if (defined $action) {
+ $c->forward($action, [$c->stash->{request}]);
+ }
+ else {
+ $c->error('no message type specified');
+ }
}
__PACKAGE__->meta->make_immutable;