From: John Napiorkowski Date: Mon, 14 Apr 2014 18:47:43 +0000 (-0500) Subject: fix for problem when a http style exception overloads stringification X-Git-Tag: 5.90062^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=6e94698dcf3a2dca78fd6f572c0860a1e386b118 fix for problem when a http style exception overloads stringification --- diff --git a/Changes b/Changes index 7bf78b6..dbd92d5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ # This file documents the revision history for Perl extension Catalyst. +5.90061 - 2014-04-14 + - HTTP::Exception objects were not properly bubbled up to middleware since + there was some code in Catalyst that was triggering stringification. + 5.90061 - 2014-03-10 - Reverted a change related to how plugins get initialized that was introduced by a change in December. diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index abf306d..571b120 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.90061'; +our $VERSION = '5.90062'; sub import { my ( $class, @arguments ) = @_; @@ -2015,12 +2015,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++; diff --git a/lib/Catalyst/Runtime.pm b/lib/Catalyst/Runtime.pm index b42b876..8466665 100644 --- a/lib/Catalyst/Runtime.pm +++ b/lib/Catalyst/Runtime.pm @@ -7,7 +7,7 @@ BEGIN { require 5.008003; } # Remember to update this in Catalyst as well! -our $VERSION = '5.90061'; +our $VERSION = '5.90062'; =head1 NAME diff --git a/t/http_exceptions.t b/t/http_exceptions.t index c8fae7c..460769d 100644 --- a/t/http_exceptions.t +++ b/t/http_exceptions.t @@ -12,6 +12,10 @@ use Plack::Test; { package MyApp::Exception; + use overload + # Use the overloading thet HTTP::Exception uses + bool => sub { 1 }, '""' => 'as_string', fallback => 1; + sub new { my ($class, $code, $headers, $body) = @_; return bless +{res => [$code, $headers, $body]}, $class; @@ -30,6 +34,8 @@ use Plack::Test; $responder->([$code, $headers, $body]); }; } + + sub as_string { 'bad stringy bad' } package MyApp::Controller::Root;