Shopify/Exception.pm

filter: Statementstmt 63.2% 31 / 49 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 45.4% 10 / 22 Podpod 0.0% 0 / 5 totaltotal 44.0% 41 / 93 CC 7 SCAR 23.5
CC
7
Cov
49%
__ANON__
42.0
new
6.0
extra
2.0
CRAP 10.5
« Shopify/Field/String.pm ↑ Summary Shopify/Field.pm »
1 #!/usr/bin/perl
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Basic WWW::Shopify exception class;
8 package WWW::Shopify::Exception;
9 use overload
10 1 ▶ 'fallback' => 1,
Subroutine BEGIN: called CC=1 SCAR=5.0
11 0 ▶ '""' => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
12 0 my ($exception) = @_;
13 0 ▶ if ($exception->error && ref($exception->error) && ref($exception->error) eq "HTTP::Response") {
Branch: 1 branch
BranchTrueFalseTotal
if ($exception->error and ref $exception->error and ref $exception->error eq "HTTP::Response") 0 0 0
Condition0%0/6
$exception->error and ref $exception->error and ref $exception->error eq "HTTP::Response"
!ll&&!rl&&r
000
$exception->error and ref $exception->error
!ll&&!rl&&r
000
MC/DC0%0/3
$exception->error and ref $exception->error and ref $exception->error eq "HTTP::Response"
$exception->error ref $exception->error ref $exception->error eq "HTTP::Response"
Truth table0%0/4
A and B and C
A= $exception->errorB= ref $exception->errorC= ref $exception->error eq "HTTP::Response"
ABCresult
0XX0
10X0
1100
1111
14 0 my $code = $exception->error->code;
15 0 ▶ my $message = $exception->error->message ? $exception->error->message : "N/A";
Branch: 1 branch
BranchTrueFalseTotal
$exception->error->message ? : 0 0 0
16 0 ▶ my $content = $exception->error->decoded_content ? $exception->error->decoded_content : "N/A";
Branch: 1 branch
BranchTrueFalseTotal
$exception->error->decoded_content ? : 0 0 0
17 0 return "Error: HTTP $code : $message\n$content\n" . $exception->stack;
18 }
19 0 return "Error: " . $exception->error . "\n" . $exception->stack;
20 1 };
21 # Generic constructor; class is blessed with the package that new specifies, and contains a hash specified inside the parentheses of a new call.
22 # Example: new WWW::Shopify::Exception('try' => 'catch'); $_[0] is 'WWW::Shopify::Exception', $_[1] is {'try' => 'catch'}.
23 # The object will be of type WWW::Shopify::Exception, and have the contents of {'try' => 'catch'}.
24 0 ▶sub new { return bless {'error' => $_[1] ? $_[1] : $_[0]->default_error, 'stack' => Devel::StackTrace->new, extra => $_[2]}, $_[0]; }
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 0 0 0
25 0 ▶sub extra { return $_[0]->{extra}; }
Subroutine extra: not called CC=1 SCAR=6.9
Pod undocumented
26 0 ▶sub error { return $_[0]->{error}; }
Subroutine error: not called CC=1 SCAR=6.9
Pod undocumented
27 0 ▶sub stack { return $_[0]->{stack}; }
Subroutine stack: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub default_error { return "Unknown exception occured."; }
Subroutine default_error: not called CC=1 SCAR=6.9
Pod undocumented
29  
30 # Thrown when a URL request exceeds the Shopify API call limit.
31 package WWW::Shopify::Exception::CallLimit;
32 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 0 ▶sub default_error { return "Call limit reached."; }
Subroutine default_error: not called CC=1 SCAR=6.9
34  
35 # Thrown from QL only.
36 package WWW::Shopify::Exception::ExceededCost;
37 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
38 0 ▶sub default_error { return "Exceeded query cost."; }
Subroutine default_error: not called CC=1 SCAR=6.9
39  
40 package WWW::Shopify::Exception::QueryParamTooLong;
41 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 0 ▶sub default_error { return "Query param too long."; }
Subroutine default_error: not called CC=1 SCAR=6.9
43  
44 package WWW::Shopify::Exception::InvalidKey;
45 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
46 0 ▶sub default_error { return "Invalid API key."; }
Subroutine default_error: not called CC=1 SCAR=6.9
47  
48 package WWW::Shopify::Exception::NotFound;
49 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
50 0 ▶sub default_error { return "Asset not found."; }
Subroutine default_error: not called CC=1 SCAR=6.9
51  
52 package WWW::Shopify::Exception::DBError;
53 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
54 0 ▶sub default_error { return "Database error."; }
Subroutine default_error: not called CC=1 SCAR=6.9
55  
56 1 1;
« Shopify/Field/String.pm ↑ Summary Shopify/Field.pm »