if ( my $error = $@ ) {
#rethow if this can be handled by middleware
- if(
- !$c->config->{always_catch_http_exceptions} &&
- blessed $error && (
- $error->can('as_psgi') ||
- (
- $error->can('code') &&
- $error->code =~m/^[1-5][0-9][0-9]$/
- )
- )
- ) {
+ if ( $c->_handle_http_exception($error) ) {
foreach my $err (@{$c->error}) {
$c->log->error($err);
}
$c->engine->finalize_error( $c, @_ );
} else {
my ($error) = @{$c->error};
- if(
- !$c->config->{always_catch_http_exceptions} &&
- blessed $error &&
- ($error->can('as_psgi') || $error->can('code'))
- ) {
+ if ( $c->_handle_http_exception($error) ) {
# In the case where the error 'knows what it wants', becauses its PSGI
# aware, just rethow and let middleware catch it
$error->can('rethrow') ? $error->rethrow : croak $error;
$status = $c->finalize;
} catch {
#rethow if this can be handled by middleware
- if(
- !$class->config->{always_catch_http_exceptions} &&
- blessed($_) && (
- $_->can('as_psgi') ||
- (
- $_->can('code') &&
- $_->code =~m/^[1-5][0-9][0-9]$/
- )
- )
- ) {
+ if ( $class->_handle_http_exception($_) ) {
$_->can('rethrow') ? $_->rethrow : croak $_;
}
chomp(my $error = $_);
};
}
+sub _handle_http_exception {
+ my ( $self, $error ) = @_;
+ if (
+ !$self->config->{always_catch_http_exceptions}
+ && blessed $error
+ && (
+ $error->can('as_psgi')
+ || ( $error->can('code')
+ && $error->code =~ m/^[1-5][0-9][0-9]$/ )
+ )
+ )
+ {
+ return 1;
+ }
+}
+
=head2 $c->stack
Returns an arrayref of the internal execution stack (actions that are