AnyEvent-EC2-Tiny
view release on metacpan or search on metacpan
lib/AnyEvent/EC2/Tiny.pm view on Meta::CPAN
$ec2->send(
...
fail_cb => sub {
my $error = shift;
if ( $error->{'type'} eq 'HTTP' ) {
# this was an HTTP error
my $http_headers = $error->{'data'}{'headers'};
my $http_body = $error->{'data'}{'body'};
warn 'HTTP error received: ', $error->{'text'};
} else {
# $error->{'type'} eq 'XML'
# this was an XML error
my $http_headers = $error->{'data'}{'headers'};
my $http_body = $error->{'data'}{'body'};
my $xml = $error->{'data'}{'xml'};
my $xml_errors = $error->{'data'}{'errors'};
warn "XML error received: ', $error->{'text'};
}
},
);
Since we can't simply C<die> or C<croak> in event-based code (the event loop
would catch it and you won't be able to do much about it), we instead provide
a failure callback. The failure callback receives a hash reference including
all information relevant to the request.
These are the available keys in the returned hash reference:
=over 4
=item C<type>
Either B<HTTP> or B<XML>.
Since there are two possible failures (one being the HTTP request, and the
other being any problems expressed in the XML returned) you can use the C<type>
key to know which type of error you received.
=item C<data>
Additional information for the error.
B<HTTP> error receives the HTTP body (C<body>) and headers (C<headers>).
B<XML> error receives the HTTP body (C<body>), headers (C<headers>), XML data
(C<xml>) and XML errors (C<errors>).
=item C<text>
A string containing the error that occured. This matches the errors returned
by L<Net::EC2::Tiny>.
=back
=head1 CREDITS
Credit goes to Mark Allen for L<Net::EC2::Tiny>.
=head1 AUTHOR
Sawyer X <xsawyerx@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Sawyer X.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.749 second using v1.01-cache-2.11-cpan-5837b0d9d2c )