X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize.pm;h=2c231515f06a9e46fda19b6ed57e988c5489384a;hb=878b2b54fb06f18f019df1f380a12ebec9585195;hp=47c150acb93f84c449b562430768de8ae76d4cec;hpb=5cb5f6bb8bd7e95865e8e3eb238b482aa161aa0d;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index 47c150a..2c23151 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -1,15 +1,9 @@ -# -# Catlyst::Action::Serialize.pm -# Created by: Adam Jacob, Marchex, -# -# $Id$ - package Catalyst::Action::Serialize; -use strict; -use warnings; +use Moose; +use namespace::autoclean; -use base 'Catalyst::Action::SerializeBase'; +extends 'Catalyst::Action::SerializeBase'; use Module::Pluggable::Object; use MRO::Compat; @@ -40,15 +34,17 @@ sub execute { "Serializing with $sclass" . ( $sarg ? " [$sarg]" : '' ) ) if $c->debug; my $rc; - if ( defined($sarg) ) { - $rc = $sclass->execute( $controller, $c, $sarg ); - } else { - $rc = $sclass->execute( $controller, $c ); - } - if ( $rc eq 0 ) { + eval { + if ( defined($sarg) ) { + $rc = $sclass->execute( $controller, $c, $sarg ); + } else { + $rc = $sclass->execute( $controller, $c ); + } + }; + if ($@) { + return $self->_serialize_bad_request( $c, $content_type, $@ ); + } elsif (!$rc) { return $self->_unsupported_media_type( $c, $content_type ); - } elsif ( $rc ne 1 ) { - return $self->_serialize_bad_request( $c, $content_type, $rc ); } return 1;