| 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
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table50%1/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table0%0/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
+(shift())->{"type"} // ""
+(shift())->{"type"}
Truth table0%0/2
A
A= +(shift())->{"type"}
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
$self->{"type"} // ""
$self->{"type"}
Truth table50%1/2
A
A= $self->{"type"}
| |||||||||||||
| 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
| |||||||||||||
| 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"} // ""
MC/DC0%0/1
$self->{"type"} // ""
$self->{"type"}
Truth table0%0/2
A
A= $self->{"type"}
| |||||||||||||
| 52 | |||||||||||||
| 53 | # These may succeed if retried after a delay | ||||||||||||
| 54 | 0 | ▶ | return 1 if $type =~ /^(BUSY|LOADING|READONLY|CLUSTERDOWN)$/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 55 | |||||||||||||
| 56 | 0 | return 0; | |||||||||||
| 57 | } | ||||||||||||
| 58 | |||||||||||||
| 59 | 92 | 1; | |||||||||||
| 60 | |||||||||||||
| 61 | __END__ | ||||||||||||