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=1f6db7d1d09e8d06b7791678490693c72793b66c;hpb=def65dcc8983843dd6da4a40e03ee6fbded2b69a;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize.pm b/lib/Catalyst/Action/Serialize.pm index 1f6db7d..0ce4558 100644 --- a/lib/Catalyst/Action/Serialize.pm +++ b/lib/Catalyst/Action/Serialize.pm @@ -1,18 +1,15 @@ -# -# 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; +our $VERSION = '0.81'; +$VERSION = eval $VERSION; + sub execute { my $self = shift; my ( $controller, $c ) = @_; @@ -32,7 +29,7 @@ sub execute { $c->log->info("Could not find a serializer for $content_type"); } else { $c->log->info( - "Could not find a serializer for an empty content type"); + "Could not find a serializer for an empty content-type"); } return 1; } @@ -40,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; @@ -137,15 +136,12 @@ a sensible set of defaults for doing a REST controller. L, L -=head1 AUTHOR - -Adam Jacob , with lots of help from mst and jrockway +=head1 AUTHORS -Marchex, Inc. paid me while I developed this module. (http://www.marchex.com) +See L for authors. =head1 LICENSE You may distribute this code under the same terms as Perl itself. =cut -