NAME
Catalyst::ActionRole::RenderErrors - Automatically return an error page
SYNOPSIS
package Example::Controller::Root;
use Moose;
use MooseX::MethodAttributes;
extends 'Catalyst::Controller';
sub root :Chained(/) PathPart('') CaptureArgs(0) {}
sub not_found :Chained(root) PathPart('') Args {
my ($self, $c, @args) = @_;
$c->detach_error(404);
}
sub die :Chained(root) PathPart(die) Args(0) {
die "saefdsdfsfs";
}
sub end :Does(RenderErrors) { }
__PACKAGE__->config(namespace=>'');
__PACKAGE__->meta->make_immutable;
DESCRIPTION
Tries to convert the last error in '$c->error' to something we can dispatch an error view too.
If the first error in '$c->error' is an object that looks like it does CatalystX::Utils::DoesHttpException then we use that error to get the HTTP status code and any additional arguments. If its not then we just return a simple HTTP 500 Bad request. In that case we won't return any information in $c-
error> since that might leak sensitiver Perl debugging info. A stringified version of the error is sent to the error log.
Useful for API work since the default Catalyst error page is in HTML and if your client is requesting JSON we'll return a properly formatted response in application/json
.
NOTE if you are in CATALYST_DEBUG mode then all HTTP 500 errors and non specific errors will still dump the development debugging error screen.