[Catalyst-commits] r13038 - in Catalyst-View-TT/branches/render_die: . lib/Catalyst/View t/lib

theory at dev.catalyst.perl.org theory at dev.catalyst.perl.org
Wed Mar 10 18:24:49 GMT 2010


Author: theory
Date: 2010-03-10 18:24:49 +0000 (Wed, 10 Mar 2010)
New Revision: 13038

Modified:
   Catalyst-View-TT/branches/render_die/Changes
   Catalyst-View-TT/branches/render_die/lib/Catalyst/View/TT.pm
   Catalyst-View-TT/branches/render_die/t/lib/TestApp.pm
Log:
Have render() warn on exception, rather than die.

This is at mst's request, to minimize backward compatibility issues. To
silence the warning, pass `render_die => 0` to the constructor. Better yet,
pass 'render_die => 1' to make it die instead of returning the excption. This
will be the default in a future release.



Modified: Catalyst-View-TT/branches/render_die/Changes
===================================================================
--- Catalyst-View-TT/branches/render_die/Changes	2010-03-08 21:39:59 UTC (rev 13037)
+++ Catalyst-View-TT/branches/render_die/Changes	2010-03-10 18:24:49 UTC (rev 13038)
@@ -1,7 +1,10 @@
 Revision history for Perl extension Catalyst::View::TT.
 
-        - The "render()" method now dies on exception, rather than returning
-          the exception object.
+        - The "render()" method now throws a warning on exception before
+          returning the exception. To silence the warning, pass 'render_die =>
+          0' to the constructor. Better yet, pass 'render_die => 1' to make it
+          die instead of returning the excption. This will be the default in a
+          future release.
 
 0.32    2010-02-16 05:55:00
         - Various documentation improvements.

Modified: Catalyst-View-TT/branches/render_die/lib/Catalyst/View/TT.pm
===================================================================
--- Catalyst-View-TT/branches/render_die/lib/Catalyst/View/TT.pm	2010-03-08 21:39:59 UTC (rev 13037)
+++ Catalyst-View-TT/branches/render_die/lib/Catalyst/View/TT.pm	2010-03-10 18:24:49 UTC (rev 13038)
@@ -241,8 +241,15 @@
         [ @{ $vars->{additional_template_paths} }, @{ $self->{include_path} } ]
         if ref $vars->{additional_template_paths};
 
-    $self->template->process( $template, $vars, \$output )
-        or die $self->template->error;
+    unless ( $self->template->process( $template, $vars, \$output ) ) {
+        if (exists $self->{render_die}) {
+            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');
+        return $self->template->error;
+    }
     return $output;
 }
 

Modified: Catalyst-View-TT/branches/render_die/t/lib/TestApp.pm
===================================================================
--- Catalyst-View-TT/branches/render_die/t/lib/TestApp.pm	2010-03-08 21:39:59 UTC (rev 13037)
+++ Catalyst-View-TT/branches/render_die/t/lib/TestApp.pm	2010-03-10 18:24:49 UTC (rev 13038)
@@ -16,6 +16,7 @@
         PRE_CHOMP          => 1,
         POST_CHOMP         => 1,
         TEMPLATE_EXTENSION => '.tt',
+        render_die         => 1,
     },
 );
 




More information about the Catalyst-commits mailing list