Net/Amazon/S3/Error/Handler/X.pm

filter: Statementstmt 100% 14 / 14 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 94.7% 18 / 19 SCAR 6.9
CC
2
Cov
94%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Shared/Examples/Net/Amazon/S3/Fixture.pm ↑ Summary Net/Amazon/S3/Operation/Object/Fetch/Request.pm »
1 package Net::Amazon::S3::Error::Handler::X;
2 1 $Net::Amazon::S3::Error::Handler::X::VERSION = '0.991';
3 # ABSTRACT: Throw error specific exception
4  
5 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 extends 'Net::Amazon::S3::Error::Handler';
8  
9 1 ▶use Net::Amazon::S3::X;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 override handle_error => sub {
12 8 ▶ my ($self, $response, $request) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
13  
14 8 ▶ return 1 unless $response->is_error;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_error 0 8 8
15  
16 8 my $exception = Net::Amazon::S3::X->build (
17 $response->error_code,
18 request => $request,
19 response => $response,
20 );
21  
22 8 die $exception;
23 1 };
24  
25 1 1;
26  
27 __END__
28  
29 =pod
30  
31 =encoding UTF-8
32  
33 =head1 NAME
34  
35 Net::Amazon::S3::Error::Handler::X - Throw error specific exception
36  
37 =head1 VERSION
38  
39 version 0.991
40  
41 =head1 DESCRIPTION
42  
43 Raise error specific exception.
44  
45 =head2 S3 error
46  
47 For S3 errors exception it raises is instance of C<Net::Amazon::S3::X::error-code>.
48 AWS error code list can be found at L<https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html#ErrorCodeList>
49  
50 my $s3 = Net::Amazon::S3->new (
51 error_handler_class => 'Net::Amazon::S3::Error::Handler::X',
52 ...
53 );
54  
55 eval { do s3 operation; 1 } or do {
56 say 'access denied'
57 if $@->$Safe::Isa::_isa ('Net::Amazon::S3::X::AccessDenied');
58 ...
59 };
60  
61 =head1 AUTHOR
62  
63 Branislav Zahradník <barney@cpan.org>
64  
65 =head1 COPYRIGHT AND LICENSE
66  
67 This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.
68  
69 This is free software; you can redistribute it and/or modify it under
70 the same terms as the Perl 5 programming language system itself.
71  
72 =cut
« Shared/Examples/Net/Amazon/S3/Fixture.pm ↑ Summary Net/Amazon/S3/Operation/Object/Fetch/Request.pm »