Pg/Error.pm

filter: Statementstmt 95.5% 43 / 45 Branchbran 0.0% 0 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 95.6% 22 / 23 Podpod 0.0% 0 / 3 totaltotal 86.8% 66 / 76 CC 3 SCAR 4.0
CC
3
Cov
90%
throw
6.0
_state_from_code
2.1
BEGIN
1.0
CRAP 1.5
« Pg/Results.pm ↑ Summary Pg.pm »
1 package IO::Async::Pg::Error;
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  
6 use overload
7 1 ▶ '""' => sub { shift->message },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
8 3 ▶ 'bool' => sub { 1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
9 1 fallback => 1;
10  
11 6 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 6 my ($class, %args) = @_;
13 6 return bless \%args, $class;
14 }
15  
16 2 ▶sub message { shift->{message} }
Subroutine message: called CC=1 SCAR=0.0
Pod undocumented
17  
18 0 ▶sub throw {
Subroutine throw: not called CC=2 SCAR=17.9
Pod undocumented
19 0 my $self = shift;
20 0 ▶ die ref $self ? $self : $self->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 0 0 0
21 }
22  
23 # SQLSTATE code to human-readable state name mapping
24 1 my %STATE_MAP = (
25 '23505' => 'unique_violation',
26 '23503' => 'foreign_key_violation',
27 '23502' => 'not_null_violation',
28 '23514' => 'check_violation',
29 '23P01' => 'exclusion_violation',
30 '42601' => 'syntax_error',
31 '42501' => 'insufficient_privilege',
32 '42P01' => 'undefined_table',
33 '42703' => 'undefined_column',
34 '42883' => 'undefined_function',
35 '40001' => 'serialization_failure',
36 '40P01' => 'deadlock_detected',
37 '57014' => 'query_canceled',
38 '08000' => 'connection_exception',
39 '08003' => 'connection_does_not_exist',
40 '08006' => 'connection_failure',
41 );
42  
43 1 ▶sub _state_from_code {
Subroutine _state_from_code: called CC=2 SCAR=7.2
44 1 my ($code) = @_;
45 1 ▶ return $STATE_MAP{$code} // 'unknown';
Condition50%1/2
$STATE_MAP{$code} // "unknown"
l!l
10
MC/DC0%0/1
$STATE_MAP{$code} // "unknown"
$STATE_MAP{$code}
Truth table50%1/2
A
A= $STATE_MAP{$code}
Aresult
11
00
46 }
47  
48  
49 package IO::Async::Pg::Error::Query;
50  
51 1 ▶use parent -norequire, 'IO::Async::Pg::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
52  
53 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
54 2 my ($class, %args) = @_;
55 2 my $self = $class->SUPER::new(%args);
56 2 return $self;
57 }
58  
59 2 ▶sub code { shift->{code} }
Subroutine code: called CC=1 SCAR=0.0
60 1 ▶sub constraint { shift->{constraint} }
Subroutine constraint: called CC=1 SCAR=0.0
61 1 ▶sub detail { shift->{detail} }
Subroutine detail: called CC=1 SCAR=0.0
62 1 ▶sub hint { shift->{hint} }
Subroutine hint: called CC=1 SCAR=0.0
63 1 ▶sub position { shift->{position} }
Subroutine position: called CC=1 SCAR=0.0
64  
65 1 ▶sub state {
Subroutine state: called CC=1 SCAR=0.0
66 1 my $self = shift;
67 1 return IO::Async::Pg::Error::_state_from_code($self->{code});
68 }
69  
70  
71 package IO::Async::Pg::Error::Connection;
72  
73 1 ▶use parent -norequire, 'IO::Async::Pg::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 1 ▶sub dsn { shift->{dsn} }
Subroutine dsn: called CC=1 SCAR=0.0
76  
77  
78 package IO::Async::Pg::Error::PoolExhausted;
79  
80 1 ▶use parent -norequire, 'IO::Async::Pg::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 1 ▶sub pool_size { shift->{pool_size} }
Subroutine pool_size: called CC=1 SCAR=0.0
83  
84  
85 package IO::Async::Pg::Error::Timeout;
86  
87 1 ▶use parent -norequire, 'IO::Async::Pg::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
88  
89 1 ▶sub timeout { shift->{timeout} }
Subroutine timeout: called CC=1 SCAR=0.0
90  
91  
92 1 1;
93  
94 __END__
« Pg/Results.pm ↑ Summary Pg.pm »