[Catalyst-commits] r13132 - Catalyst-View-TT/trunk/lib/Catalyst/View

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Wed Apr 7 02:51:15 GMT 2010


Author: t0m
Date: 2010-04-07 03:51:15 +0100 (Wed, 07 Apr 2010)
New Revision: 13132

Modified:
   Catalyst-View-TT/trunk/lib/Catalyst/View/TT.pm
Log:
Fix error reporting to work correctly even when render_die => 0. RT#55766

Modified: Catalyst-View-TT/trunk/lib/Catalyst/View/TT.pm
===================================================================
--- Catalyst-View-TT/trunk/lib/Catalyst/View/TT.pm	2010-04-07 01:23:28 UTC (rev 13131)
+++ Catalyst-View-TT/trunk/lib/Catalyst/View/TT.pm	2010-04-07 02:51:15 UTC (rev 13132)
@@ -8,6 +8,7 @@
 use Template;
 use Template::Timer;
 use MRO::Compat;
+use Scalar::Util qw/blessed/;
 
 our $VERSION = '0.33';
 
@@ -213,11 +214,11 @@
     local $@;
     my $output = eval { $self->render($c, $template) };
     if (my $err = $@) {
-        my $error = qq/Couldn't render template "$template"/;
-        $c->log->error($error);
-        $c->error($error);
-        return 0;
+        return $self->_rendering_error($c, $err);
     }
+    if (blessed($output) && $output->isa('Template::Exception')) {
+        $self->_rendering_error($c, $output);
+    }
 
     unless ( $c->response->content_type ) {
         $c->response->content_type('text/html; charset=utf-8');
@@ -228,6 +229,14 @@
     return 1;
 }
 
+sub _rendering_error {
+    my ($self, $c, $err) = @_;
+    my $error = qq/Couldn't render template "$err"/;
+    $c->log->error($error);
+    $c->error($error);
+    return 0;
+}
+
 sub render {
     my ($self, $c, $template, $args) = @_;
 
@@ -248,8 +257,7 @@
             die $self->template->error if $self->{render_die};
             return $self->template->error;
         }
-        require Carp;
-        Carp::carp('The Catalyst::View::TT render() method of will die on error in a future release. If you want it to continue to return the exception instead, pass render_die => 0 to the constructor');
+        $c->log->debug('The Catalyst::View::TT render() method of will die on error in a future release. Unless you are calling the render() method manually, you probably want the new behaviour, so set render_die => 1 in config for ' . blessed($self) . '. If you are calling the render() method manually and you wish it to continue to return the exception rather than throwing it, add render_die => 0 to your config.') if $c->debug;
         return $self->template->error;
     }
     return $output;




More information about the Catalyst-commits mailing list