blib/lib/WWW/FBX/Error.pm

filter: Statementstmt 54.7% 23 / 42 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 50.0% 6 / 12 Podpod 0.0% 0 / 3 totaltotal 27.6% 29 / 105 CC 15 SCAR 28.2
CC
15
Cov
30%
__ANON__
30.0
error
30.0
fbx_error_code
20.0
CRAP 16.8
↑ Summary blib/lib/WWW/FBX/Role/Auth.pm »
1 package WWW::FBX::Error;
2 22 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 22 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use Devel::StackTrace;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 #Stringify using error sub
8 22 use overload '""' => \&error,
9 22 ▶ 'fallback' => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 22 has fbx_error => ( is => 'rw', predicate => 'has_fbx_error' );
13 22 has http_response => ( isa => 'HTTP::Response', is => 'rw', required => 1, handles => [qw/code message/] );
14 22 has stack_trace => ( is => 'ro', init_arg => undef, builder => '_build_stack_trace' );
15 22 has _stringified => ( is => 'rw', init_arg => undef, default => undef );
16  
17 sub _build_stack_trace {
18 0 ▶ my $seen;
Subroutine _build_stack_trace: not called CC=1 SCAR=6.9
19 0 my $this_sub = (caller 0)[3];
20 Devel::StackTrace->new(frame_filter => sub {
21 0 ▶ my $caller = shift->{caller};
Subroutine __ANON__: not called CC=5 SCAR=34.0
22 0 ▶ my $in_nt = $caller->[0] =~ /^WWW::Net::/ || $caller->[3] eq $this_sub;
Condition0%0/3
$caller->[0] =~ /^WWW::Net::/ || $caller->[3] eq $this_sub
l!l&&r!l&&!r
000
MC/DC0%0/2
$caller->[0] =~ /^WWW::Net::/ || $caller->[3] eq $this_sub
$caller->[0] =~ /^WWW::Net::/ $caller->[3] eq $this_sub
Truth table0%0/3
A || B
A= $caller->[0] =~ /^WWW::Net::/B= $caller->[3] eq $this_sub
ABresult
1X1
011
000
23 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
24 0 });
25 }
26  
27 sub error {
28 0 ▶ my $self = shift;
Subroutine error: not called CC=5 SCAR=34.0
Pod undocumented
29  
30 0 ▶ return $self->_stringified if $self->_stringified;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_stringified 0 0 0
31  
32 # Don't walk on $@
33 0 local $@;
34  
35 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
36 || $self->http_response->status_line;
37  
38 0 my ($location) = $self->stack_trace->frame(0)->as_string =~ /( at .*)/;
39 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
40 }
41  
42 sub fbx_error_text {
43 0 ▶ my $self = shift;
Subroutine fbx_error_text: not called CC=3 SCAR=24.8
Pod undocumented
44  
45  
46 0 ▶ return '' unless $self->has_fbx_error;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->has_fbx_error 0 0 0
47 0 my $e = $self->fbx_error;
48  
49 return try {
50 0 ▶ exists $e->{msg} && $e->{msg};
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
exists $e->{"msg"} and $e->{"msg"} 0 0 0
51 0 ▶ } || '';
Condition0%0/2
&try(sub { || ''
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
52 }
53  
54  
55 sub fbx_error_code {
56 0 ▶ my $self = shift;
Subroutine fbx_error_code: not called CC=4 SCAR=30.0
Pod undocumented
57  
58 return $self->has_fbx_error
59 && exists $self->fbx_error->{error_code}
60 && $self->fbx_error->{error_code}
61 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
62 }
63  
64 22 __PACKAGE__->meta->make_immutable;
65  
66 22 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
67  
68  
69 22 1;
70 __END__
71  
72 =encoding utf-8
73  
74 =head1 NAME
75  
76 WWW::FBX::Error - Freebox Error Handling
77  
78 =head1 SYNOPSIS
79  
80 use WWW::FBX::Error;
81  
82 =head1 DESCRIPTION
83  
84 WWW::FBX::Error is FBX Error handling
85  
86 =head1 LICENSE
87  
88 Copyright (C) Laurent Kislaire.
89  
90 This library is free software; you can redistribute it and/or modify
91 it under the same terms as Perl itself.
92  
93 =head1 AUTHOR
94  
95 Laurent Kislaire E<lt>teebeenator@gmail.comE<gt>
96  
97 =cut
98  
↑ Summary blib/lib/WWW/FBX/Role/Auth.pm »