-#
-# Catlyst::Action::Serialize.pm
-# Created by: Adam Jacob, Marchex, <adam@hjksolutions.com>
-#
-# $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 ) = @_;
"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;
L<Catalyst::Action::Deserialize>, L<Catalyst::Action::REST>
-=head1 AUTHOR
-
-Adam Jacob <adam@stalecoffee.org>, 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<Catalyst::Action::REST> for authors.
=head1 LICENSE