Amazon-API
view release on metacpan or search on metacpan
lib/Amazon/API/Error.pm view on Meta::CPAN
package Amazon::API::Error;
use parent qw/Class::Accessor/;
use JSON qw/from_json/;
use Scalar::Util qw/reftype/;
use XML::Simple;
__PACKAGE__->follow_best_practice;
__PACKAGE__->mk_accessors(qw/error api message_raw response content_type/);
our $VERSION = '1.1.4-1'; $VERSION=~s/\-.*$//;
=pod
=head1 NAME
C<Amazon::API::Error>
=head1 SYNOPIS
my $result = eval {
from_json($cwe->PutPermission({ Action => "PutEvents", Principal => "123454657889012", StatementId => "12345"});
};
print Dumper([ $@->get_response, $@->get_error ])
if $@ && ref($@) =~/API::Error/;
=head1 DESCRIPTION
Error object that contains that status code and the error message
contained in the body of the response to the API call.
=head1 METHODS
=head2 get_error
Returns the HTTP status code returned by the API call.
=head2 get_response
Returns a decode response. Usuall a hash.
=head2 get_message_raw
Returns the content of the body of the error response.
=head2 get_content_type
Returns the Content-Type of the response.
=head2 get_aws_api
Returns the API that was called that generated the error.
=head1 NOTES
An example response:
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>UnauthorizedOperation</Code><Message>You are not authorized to perform this operation.</Message></Error></Errors><RequestID>599b0f86-4668-4adb-b493-552d6039fcd1</RequestID></Response>
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
my $message = $self->get_message_raw;
( run in 0.631 second using v1.01-cache-2.11-cpan-39bf76dae61 )