X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize%2FView.pm;h=286fc889ca3d8eb723f9b1facb8450c5d87419e7;hb=067d48ee88e1337e1bfc35b56188fbb438377155;hp=09ee45b07a19fd38fd0ecf24f0f4079d30d0b9af;hpb=faf5c20bff09c91f18b46a3d3d8349379aa36192;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize/View.pm b/lib/Catalyst/Action/Serialize/View.pm index 09ee45b..286fc88 100644 --- a/lib/Catalyst/Action/Serialize/View.pm +++ b/lib/Catalyst/Action/Serialize/View.pm @@ -1,25 +1,33 @@ package Catalyst::Action::Serialize::View; -use strict; -use warnings; +use Moose; +use namespace::autoclean; -use base 'Catalyst::Action'; +extends 'Catalyst::Action'; sub execute { my $self = shift; my ( $controller, $c, $view ) = @_; my $stash_key = ( - $controller->config->{'serialize'} ? - $controller->config->{'serialize'}->{'stash_key'} : - $controller->config->{'stash_key'} + $controller->{'serialize'} ? + $controller->{'serialize'}->{'stash_key'} : + $controller->{'stash_key'} ) || 'rest'; if ( !$c->view($view) ) { $c->log->error("Could not load $view, refusing to serialize"); - return 0; + return; } - return $c->view($view)->process($c); + if ($c->view($view)->process($c, $stash_key)) { + return 1; + } else { + # This is stupid. Please improve it. + my $error = join("\n", @{ $c->error }) || "Error in $view"; + $error .= "\n"; + $c->clear_errors; + die $error; + } } 1;