blib/lib/Async/Redis/Error/Redis.pm

filter: Statementstmt 82.3% 28 / 34 Branchbran 50.0% 3 / 6 Conditioncond 35.0% 7 / 20 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 81.2% 13 / 16 Podpod 100% 12 / 12 totaltotal 64.2% 63 / 98 CC 14 SCAR 12.8
CC
14
Cov
63%
is_transient
12.0
is_noauth
6.0
is_noperm
6.0
CRAP 3.6
« blib/lib/Async/Redis/KeyExtractor.pm ↑ Summary blib/lib/Async/Redis/Commands.pm »
1 package Async::Redis::Error::Redis;
2  
3 92 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 92 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 92 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 92 ▶use parent 'Async::Redis::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶sub type { shift->{type} }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
10  
11 # Parse error type from Redis error message
12 # Redis errors are formatted as: "ERRORTYPE message text"
13 4 ▶sub from_message {
Subroutine from_message: called CC=2 SCAR=7.0
Pod documented
14 4 my ($class, $message) = @_;
15  
16 4 my $type = 'ERR'; # default
17 4 ▶ if ($message =~ /^([A-Z]+)\s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($message =~ /^([A-Z]+)\s/u) 4 0 4
18 4 $type = $1;
19 }
20  
21 4 return $class->new(
22 message => $message,
23 type => $type,
24 );
25 }
26  
27 # Predicate methods for common error types
28 7 ▶sub is_wrongtype { uc(shift->{type} // '') eq 'WRONGTYPE' }
Subroutine is_wrongtype: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
70
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
29 7 ▶sub is_oom { uc(shift->{type} // '') eq 'OOM' }
Subroutine is_oom: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
70
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
30 7 ▶sub is_busy { uc(shift->{type} // '') eq 'BUSY' }
Subroutine is_busy: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
70
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
31 6 ▶sub is_noscript { uc(shift->{type} // '') eq 'NOSCRIPT' }
Subroutine is_noscript: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
60
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
32 6 ▶sub is_readonly { uc(shift->{type} // '') eq 'READONLY' }
Subroutine is_readonly: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
60
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
33 7 ▶sub is_loading { uc(shift->{type} // '') eq 'LOADING' }
Subroutine is_loading: called CC=2 SCAR=7.6
Pod documented
Condition50%1/2
+(shift())->{"type"} // ""
l!l
70
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
Aresult
11
00
34 0 ▶sub is_noauth { uc(shift->{type} // '') eq 'NOAUTH' }
Subroutine is_noauth: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
+(shift())->{"type"} // ""
l!l
00
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table0%0/2
A
A= +(shift())->{"type"}
Aresult
11
00
35 0 ▶sub is_noperm { uc(shift->{type} // '') eq 'NOPERM' }
Subroutine is_noperm: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
+(shift())->{"type"} // ""
l!l
00
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table0%0/2
A
A= +(shift())->{"type"}
Aresult
11
00
36  
37 # Fatal errors should not be retried
38 7 ▶sub is_fatal {
Subroutine is_fatal: called CC=3 SCAR=11.0
Pod documented
39 7 my $self = shift;
40 7 ▶ my $type = uc($self->{type} // '');
Condition50%1/2
$self->{"type"} // ""
l!l
70
MC/DC0%0/1
$self->{"type"} // ""
$self->{"type"}
Truth table50%1/2
A
A= $self->{"type"}
Aresult
11
00
41  
42 # These are deterministic failures - retrying won't help
43 7 ▶ return 1 if $type =~ /^(WRONGTYPE|OOM|NOSCRIPT|NOAUTH|NOPERM|ERR)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /^(WRONGTYPE|OOM|NOSCRIPT|NOAUTH|NOPERM|ERR)$/u 4 3 7
44  
45 3 return 0;
46 }
47  
48 # Transient errors may succeed on retry
49 0 ▶sub is_transient {
Subroutine is_transient: not called CC=3 SCAR=24.8
Pod documented
50 0 my $self = shift;
51 0 ▶ my $type = uc($self->{type} // '');
Condition0%0/2
$self->{"type"} // ""
l!l
00
MC/DC0%0/1
$self->{"type"} // ""
$self->{"type"}
Truth table0%0/2
A
A= $self->{"type"}
Aresult
11
00
52  
53 # These may succeed if retried after a delay
54 0 ▶ return 1 if $type =~ /^(BUSY|LOADING|READONLY|CLUSTERDOWN)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /^(BUSY|LOADING|READONLY|CLUSTERDOWN)$/u 0 0 0
55  
56 0 return 0;
57 }
58  
59 92 1;
60  
61 __END__
« blib/lib/Async/Redis/KeyExtractor.pm ↑ Summary blib/lib/Async/Redis/Commands.pm »