blib/lib/WWW/Shopify/Exception.pm

filter: Statementstmt 75.6% 31 / 41 Branchbran 25.0% 2 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 66.6% 12 / 18 Podpod 0.0% 0 / 5 totaltotal 59.2% 48 / 81 CC 7 SCAR 15.8
CC
7
Cov
65%
__ANON__
15.1
new
2.1
extra
2.0
CRAP 4.9
« blib/lib/WWW/Shopify/Field.pm ↑ Summary blib/lib/WWW/Shopify/Model/LinkList.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 'fallback' => 1,
11 '""' => sub {
12 3372 ▶ my ($exception) = @_;
Subroutine __ANON__: called CC=6 SCAR=27.1
13 3372 ▶ 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 3372 3372
Condition50%3/6
$exception->error and ref $exception->error and ref $exception->error eq "HTTP::Response"
!ll&&!rl&&r
28105620
$exception->error and ref $exception->error
!ll&&!rl&&r
033720
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 table25%1/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 3372 return "Error: " . $exception->error . "\n" . $exception->stack;
20 1 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
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 562 ▶sub new { return bless {'error' => $_[1] ? $_[1] : $_[0]->default_error, 'stack' => Devel::StackTrace->new, extra => $_[2]}, $_[0]; }
Subroutine new: called CC=2 SCAR=7.6
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 562 0 562
25 0 ▶sub extra { return $_[0]->{extra}; }
Subroutine extra: not called CC=1 SCAR=6.9
Pod undocumented
26 10678 ▶sub error { return $_[0]->{error}; }
Subroutine error: called CC=1 SCAR=0.0
Pod undocumented
27 3372 ▶sub stack { return $_[0]->{stack}; }
Subroutine stack: called CC=1 SCAR=0.0
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 package WWW::Shopify::Exception::InvalidKey;
36 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
37 0 ▶sub default_error { return "Invalid API key."; }
Subroutine default_error: not called CC=1 SCAR=6.9
38  
39 package WWW::Shopify::Exception::NotFound;
40 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 0 ▶sub default_error { return "Asset not found."; }
Subroutine default_error: not called CC=1 SCAR=6.9
42  
43 package WWW::Shopify::Exception::DBError;
44 1 ▶use parent 'WWW::Shopify::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 0 ▶sub default_error { return "Database error."; }
Subroutine default_error: not called CC=1 SCAR=6.9
46  
47 1 1;
« blib/lib/WWW/Shopify/Field.pm ↑ Summary blib/lib/WWW/Shopify/Model/LinkList.pm »