File Coverage

blib/lib/Net/Amazon/S3/Error/Handler/Legacy.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


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