X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize.pm;h=0ce455826dc608822cf73af20c2d9ba59d2880ba;hb=f465980c3c25b475d878716b7341d0a4f5c8f823;hp=d47f97c160a4ab9588b5915e3aacd65ed0857ec2;hpb=930013e6f19b25a090c3f8839495ad8d9b15ff6d;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index d47f97c..0ce4558 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -7,6 +7,9 @@ extends 'Catalyst::Action::SerializeBase'; use Module::Pluggable::Object; use MRO::Compat; +our $VERSION = '0.81'; +$VERSION = eval $VERSION; + sub execute { my $self = shift; my ( $controller, $c ) = @_; @@ -34,15 +37,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;