X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=5cebc605dc3cb26791b0f6424adc9f015731fb11;hp=24ecb73af8933b758783ec26778625e20b2856b7;hb=058e4074653139386299c58678cd852d10060056;hpb=dad411d91fa8afea93dcaef234abbde6c3dc0fa2 diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 24ecb73..5cebc60 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -204,7 +204,7 @@ sub composed_stats_class { __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90104'; +our $VERSION = '5.90106'; $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases sub import { @@ -1420,11 +1420,6 @@ EOF $class->setup_encoding(); $class->setup_middleware(); - # call these so we pre setup the composed classes - $class->composed_request_class; - $class->composed_response_class; - $class->composed_stats_class; - # Initialize our data structure $class->components( {} ); @@ -1502,6 +1497,11 @@ EOF $class->log->warn("This setting is deprecated and planned to be removed in Catalyst 5.81."); } + # call these so we pre setup the composed classes + $class->composed_request_class; + $class->composed_response_class; + $class->composed_stats_class; + $class->setup_finalize; # Flush the log for good measure (in case something turned off 'autoflush' early) @@ -2466,9 +2466,6 @@ sub prepare { # VERY ugly and probably shouldn't rely on ->finalize actually working catch { # failed prepare is always due to an invalid request, right? - $c->response->status(400); - $c->response->content_type('text/plain'); - $c->response->body('Bad Request'); # Note we call finalize and then die here, which escapes # finalize being called in the enclosing block.. # It in fact couldn't be called, as we don't return $c.. @@ -2476,8 +2473,20 @@ sub prepare { # breaking compat for people doing crazy things (we should set # the 400 and just return the ctx here IMO, letting finalize get called # above... - $c->finalize; - die $_; + if ( $c->_handle_http_exception($_) ) { + foreach my $err (@{$c->error}) { + $c->log->error($err); + } + $c->clear_errors; + $c->log->_flush if $c->log->can('_flush'); + $_->can('rethrow') ? $_->rethrow : croak $_; + } else { + $c->response->status(400); + $c->response->content_type('text/plain'); + $c->response->body('Bad Request'); + $c->finalize; + die $_; + } }; $c->log_request;