lib/WWW/FBX/Error.pm

filter: Statementstmt 57.7% 26 / 45 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 53.8% 7 / 13 Podpod 0.0% 0 / 3 totaltotal 30.2% 33 / 109 CC 15 SCAR 27.8
CC
15
Cov
32%
__ANON__
30.0
error
30.0
fbx_error_code
20.0
CRAP 16.2
« lib/WWW/FBX/Role/API/APIv3.pm ↑ Summary script/fbx-test.pl »
1 package WWW::FBX::Error;
2 23 ▶use 5.014001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 23 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 23 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 23 ▶use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #Stringify using error sub
8 23 ▶use overload '""' => \&error,
Subroutine BEGIN: called CC=1 SCAR=0.0
9 23 'fallback' => 1;
10  
11 23 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 23 has fbx_error => ( is => 'rw', predicate => 'has_fbx_error' );
15 23 has http_response => ( isa => 'HTTP::Response', is => 'rw', required => 1, handles => [qw/code message/] );
16 23 has stack_trace => ( is => 'ro', init_arg => undef, builder => '_build_stack_trace' );
17 23 has _stringified => ( is => 'rw', init_arg => undef, default => undef );
18  
19 0 ▶sub _build_stack_trace {
Subroutine _build_stack_trace: not called CC=1 SCAR=6.9
20 0 my $seen;
21 0 my $this_sub = (caller 0)[3];
22 0 ▶ Devel::StackTrace->new(frame_filter => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
23 0 my $caller = shift->{caller};
24 0 ▶ my $in_nt = $caller->[0] =~ /^WWW::Net::/ || $caller->[3] eq $this_sub;
Condition0%0/3
$caller->[0] =~ /^WWW::Net::/u || $caller->[3] eq $this_sub
l!l&&r!l&&!r
000
MC/DC0%0/2
$caller->[0] =~ /^WWW::Net::/u || $caller->[3] eq $this_sub
$caller->[0] =~ /^WWW::Net::/u $caller->[3] eq $this_sub
Truth table0%0/3
A || B
A= $caller->[0] =~ /^WWW::Net::/uB= $caller->[3] eq $this_sub
ABresult
1X1
011
000
25 0 ▶ ($seen ||= $in_nt) && !$in_nt || 0;
Branch: 1 branch
BranchTrueFalseTotal
$seen ||= $in_nt and not $in_nt or 0 0 0 0
Condition0%0/6
$seen ||= $in_nt and not $in_nt
!ll&&!rl&&r
000
$seen ||= $in_nt
l!l&&r!l&&!r
000
MC/DC0%0/3
$seen ||= $in_nt and not $in_nt
$seen $in_nt not $in_nt
Truth table0%0/5
A ||= B and not(C)
A= $seenB= $in_ntC= not $in_nt
ABCresult
00X0
1X00
0100
1X11
0111
26 0 });
27 }
28  
29 0 ▶sub error {
Subroutine error: not called CC=5 SCAR=34.0
Pod undocumented
30 0 my $self = shift;
31  
32 0 ▶ return $self->_stringified if $self->_stringified;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_stringified 0 0 0
33  
34 # Don't walk on $@
35 0 local $@;
36  
37 0 ▶ my $error = $self->has_fbx_error && $self->fbx_error_text
Condition0%0/6
$self->has_fbx_error && $self->fbx_error_text || $self->http_response->status_line
l!l&&r!l&&!r
000
$self->has_fbx_error and $self->fbx_error_text
!ll&&!rl&&r
000
MC/DC0%0/3
$self->has_fbx_error && $self->fbx_error_text || $self->http_response->status_line
$self->has_fbx_error $self->fbx_error_text $self->http_response->status_line
Truth table0%0/5
A and B || C
A= $self->has_fbx_errorB= $self->fbx_error_textC= $self->http_response->status_line
ABCresult
11X1
0X11
1011
0X00
1000
38 || $self->http_response->status_line;
39  
40 0 my ($location) = $self->stack_trace->frame(0)->as_string =~ /( at .*)/;
41 0 ▶ return $self->_stringified($error . ($location || ''));
Condition0%0/2
$location || ''
l!l
00
MC/DC0%0/1
$location || ''
$location
Truth table0%0/2
A
A= $location
Aresult
11
00
42 }
43  
44 0 ▶sub fbx_error_text {
Subroutine fbx_error_text: not called CC=3 SCAR=24.8
Pod undocumented
45 0 my $self = shift;
46  
47  
48 0 ▶ return '' unless $self->has_fbx_error;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_fbx_error 0 0 0
49 0 my $e = $self->fbx_error;
50  
51 0 ▶ return try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
52 0 ▶ exists $e->{msg} && $e->{msg};
Branch: 1 branch
BranchTrueFalseTotal
exists $e->{"msg"} and $e->{"msg"} 0 0 0
53 0 ▶ } || '';
Condition0%0/2
&try(sub { exists $e->{'msg'} and $e->{'msg'}; } ) || ''
l!l
00
MC/DC0%0/1
&try(sub { exists $e->{'msg'} and $e->{'msg'}; } ) || ''
&try(sub { exists $e->{'msg'} and $e->{'msg'}; } )
Truth table0%0/2
A
A= &try(sub { exists $e->{'msg'} and $e->{'msg'}; } )
Aresult
11
00
54 }
55  
56  
57 0 ▶sub fbx_error_code {
Subroutine fbx_error_code: not called CC=4 SCAR=30.0
Pod undocumented
58 0 my $self = shift;
59  
60 return $self->has_fbx_error
61 && exists $self->fbx_error->{error_code}
62 && $self->fbx_error->{error_code}
63 0 ▶ || 0;
Condition0%0/8
$self->has_fbx_error && exists $self->fbx_error->{'error_code'} && $self->fbx_error->{'error_code'} || 0
l!l
00
$self->has_fbx_error and exists $self->fbx_error->{"error_code"} and $self->fbx_error->{"error_code"}
!ll&&!rl&&r
000
$self->has_fbx_error and exists $self->fbx_error->{"error_code"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->has_fbx_error && exists $self->fbx_error->{'error_code'} && $self->fbx_error->{'error_code'} || 0
$self->has_fbx_error exists $self->fbx_error->{"error_code"} $self->fbx_error->{"error_code"}
Truth table0%0/4
A and B and C
A= $self->has_fbx_errorB= exists $self->fbx_error->{"error_code"}C= $self->fbx_error->{"error_code"}
ABCresult
1111
0XX0
10X0
1100
64 }
65  
66 23 __PACKAGE__->meta->make_immutable;
67  
68 23 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70  
71 23 1;
72 __END__
« lib/WWW/FBX/Role/API/APIv3.pm ↑ Summary script/fbx-test.pl »