From: John Napiorkowski Date: Fri, 6 Jun 2014 18:42:48 +0000 (-0400) Subject: make sure when http exceptions donot abort exising log or error stack X-Git-Tag: 5.90070~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=30e84ba12e66e1487b8150cc97382489e52713ca make sure when http exceptions donot abort exising log or error stack --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 2a40bc5..d8e36b7 100755 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -564,6 +564,14 @@ sub clear_errors { $c->error(0); } +=head2 $c->has_errors + +Returns true if you have errors + +=cut + +sub has_errors { scalar(@{shift->error}) ? 1:0 } + sub _comp_search_prefixes { my $c = shift; return map $c->components->{ $_ }, $c->_comp_names_search_prefixes(@_); @@ -1741,6 +1749,12 @@ sub execute { if ( my $error = $@ ) { #rethow if this can be handled by middleware if(blessed $error && ($error->can('as_psgi') || $error->can('code'))) { + foreach my $err (@{$c->error}) { + $c->log->error($err); + } + $c->clear_errors; + $c->log->_flush if $c->log->can('_flush'); + $error->can('rethrow') ? $error->rethrow : croak $error; } if ( blessed($error) and $error->isa('Catalyst::Exception::Detach') ) { @@ -1922,7 +1936,6 @@ sub finalize_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; - croak $error; } else { $c->engine->finalize_error( $c, @_ ) }