X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=3ec38fcd0307aaca4b6437f7553a12f60e082f26;hb=4477b313f9ef93789650b63e5ce408fe65ca54b2;hp=6d77f40f1ea0645377c2817bae0b609f0c627fde;hpb=b677b4c22739a063c230215b59c37a8e4e3e9a0e;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 6d77f40..3ec38fc 100755 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -126,7 +126,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90060'; +our $VERSION = '5.90062'; sub import { my ( $class, @arguments ) = @_; @@ -1133,7 +1133,6 @@ sub setup { $class->setup_log( delete $flags->{log} ); $class->setup_plugins( delete $flags->{plugins} ); - $class->setup_middleware(); $class->setup_data_handlers(); $class->setup_dispatcher( delete $flags->{dispatcher} ); if (my $engine = delete $flags->{engine}) { @@ -1174,6 +1173,8 @@ EOF $class->setup unless $Catalyst::__AM_RESTARTING; } + $class->setup_middleware(); + # Initialize our data structure $class->components( {} ); @@ -1737,6 +1738,10 @@ sub execute { my $last = pop( @{ $c->stack } ); if ( my $error = $@ ) { + #rethow if this can be handled by middleware + if(blessed $error && ($error->can('as_psgi') || $error->can('code'))) { + $error->can('rethrow') ? $error->rethrow : croak $error; + } if ( blessed($error) and $error->isa('Catalyst::Exception::Detach') ) { $error->rethrow if $c->depth > 1; } @@ -2014,12 +2019,12 @@ sub handle_request { $c->dispatch; $status = $c->finalize; } catch { - chomp(my $error = $_); - $class->log->error(qq/Caught exception in engine "$error"/); #rethow if this can be handled by middleware - if(blessed $error && ($error->can('as_psgi') || $error->can('code'))) { - $error->can('rethrow') ? $error->rethrow : croak $error; + if(blessed $_ && ($_->can('as_psgi') || $_->can('code'))) { + $_->can('rethrow') ? $_->rethrow : croak $_; } + chomp(my $error = $_); + $class->log->error(qq/Caught exception in engine "$error"/); }; $COUNT++;