| 1 | package Net::Amazon::S3::Error::Handler::Legacy; | ||||||||||
| 2 | 99 | $Net::Amazon::S3::Error::Handler::Legacy::VERSION = '0.991'; | |||||||||
| 3 | # ABSTRACT: An internal class to report errors like legacy API | ||||||||||
| 4 | |||||||||||
| 5 | 99 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 99 | extends 'Net::Amazon::S3::Error::Handler::Status'; | |||||||||
| 8 | |||||||||||
| 9 | 99 | ▶ | use HTTP::Status; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 99 | our @CARP_NOT = __PACKAGE__; | |||||||||
| 12 | |||||||||||
| 13 | 99 | my %croak_on_response = map +($_ => 1), ( | |||||||||
| 14 | 'Net::Amazon::S3::Operation::Bucket::Acl::Fetch::Response', | ||||||||||
| 15 | 'Net::Amazon::S3::Operation::Object::Acl::Fetch::Response', | ||||||||||
| 16 | 'Net::Amazon::S3::Operation::Object::Fetch::Response', | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | override handle_error => sub { | ||||||||||
| 20 | 103 | ▶ | my ($self, $response, $request) = @_; | ||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||
| 21 | |||||||||||
| 22 | 103 | ▶ | return super unless exists $croak_on_response{ref $response}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | |||||||||||
| 24 | 21 | $self->s3->err (undef); | |||||||||
| 25 | 21 | $self->s3->errstr (undef); | |||||||||
| 26 | |||||||||||
| 27 | 21 | ▶ | return 1 unless $response->is_error; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 16 | ▶ | return 0 if $response->http_response->code == HTTP::Status::HTTP_NOT_FOUND; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | |||||||||||
| 30 | 9 | $self->s3->err ("network_error"); | |||||||||
| 31 | 9 | $self->s3->errstr ($response->http_response->status_line); | |||||||||
| 32 | |||||||||||
| 33 | 9 | Carp::croak ("Net::Amazon::S3: Amazon responded with ${\ $self->s3->errstr }\n"); | |||||||||
| 34 | 99 | }; | |||||||||
| 35 | |||||||||||
| 36 | 99 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||
| 39 | |||||||||||
| 40 | =pod | ||||||||||
| 41 | |||||||||||
| 42 | =encoding UTF-8 | ||||||||||
| 43 | |||||||||||
| 44 | =head1 NAME | ||||||||||
| 45 | |||||||||||
| 46 | Net::Amazon::S3::Error::Handler::Legacy - An internal class to report errors like legacy API | ||||||||||
| 47 | |||||||||||
| 48 | =head1 VERSION | ||||||||||
| 49 | |||||||||||
| 50 | version 0.991 | ||||||||||
| 51 | |||||||||||
| 52 | =head1 DESCRIPTION | ||||||||||
| 53 | |||||||||||
| 54 | Handle errors like L<Net::Amazon::S3> API does. | ||||||||||
| 55 | |||||||||||
| 56 | Carp::croak in case of I<object fetch>, I<object acl fetch>, and I<bucket acl fetch>. | ||||||||||
| 57 | set C<err> / C<errstr> only otherwise. | ||||||||||
| 58 | |||||||||||
| 59 | =head1 AUTHOR | ||||||||||
| 60 | |||||||||||
| 61 | Branislav Zahradník <barney@cpan.org> | ||||||||||
| 62 | |||||||||||
| 63 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 64 | |||||||||||
| 65 | This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník. | ||||||||||
| 66 | |||||||||||
| 67 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 68 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 69 | |||||||||||
| 70 | =cut | ||||||||||