fix for problem when a http style exception overloads stringification 5.90062
John Napiorkowski [Mon, 14 Apr 2014 18:47:43 +0000 (13:47 -0500)]
Changes
lib/Catalyst.pm
lib/Catalyst/Runtime.pm
t/http_exceptions.t

diff --git a/Changes b/Changes
index 7bf78b6..dbd92d5 100644 (file)
--- 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.
index abf306d..571b120 100755 (executable)
@@ -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++;
index b42b876..8466665 100644 (file)
@@ -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
 
index c8fae7c..460769d 100644 (file)
@@ -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;