X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize.pm;h=2c231515f06a9e46fda19b6ed57e988c5489384a;hp=d47f97c160a4ab9588b5915e3aacd65ed0857ec2;hb=68c266124de8e212143d4b94c55982f986f6945c;hpb=0745d6ebf570fa9b75029a7c8b85e647f1a1f09e diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index d47f97c..2c23151 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -34,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;