blib/lib/DBIO/Exception/Server.pm

filter: Statementstmt 100% 34 / 34 Branchbran 90.0% 9 / 10 Conditioncond 60.0% 9 / 15 MC/DCmcdc 33.3% 3 / 9 Subroutinesub 100% 11 / 11 Podpod 100% 8 / 8 totaltotal 85.0% 74 / 87 CC 11 SCAR 13.8
CC
11
Cov
88%
with_context
6.3
new
6.1
BEGIN
1.0
CRAP 4.0
« blib/lib/DBIO/Relationship/HasMany.pm ↑ Summary blib/lib/DBIO/Test/Schema/Encoded.pm »
1 package DBIO::Exception::Server;
2 # ABSTRACT: A refusal by the database server, with its SQLSTATE
3  
4 345 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 345 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 345 our $VERSION = '0.900007';
8  
9 345 ▶use base 'DBIO::Exception';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 345 my @FIELDS = qw(sqlstate constraint table detail context);
13  
14 55 ▶sub new {
Subroutine new: called CC=6 SCAR=18.1
Pod documented
15 55 my ($class, %args) = @_;
16  
17 55 my $message = delete $args{message};
18 # a false error is no error to a Future (Future.pm refuses one) and to the
19 # `if ($@)` checks around core's evals: the text must be true
20 55 ▶ DBIO::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message and length $message and $message 2 53 55
Condition83%5/6
defined $message and length $message and $message
!ll&&!rl&&r
1153
defined $message and length $message
!ll&&!rl&&r
1054
MC/DC66%2/3
defined $message and length $message and $message
defined $message length $message $message
Truth table75%3/4
A and B and C
A= defined $messageB= length $messageC= $message
ABCresult
0XX0
10X0
1100
1111
21 'DBIO::Exception::Server->new needs a message: the text it stringifies to'
22 ) unless defined $message && length $message && $message;
23  
24 53 my %self = map { $_ => delete $args{$_} } @FIELDS;
25 53 ▶ DBIO::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if %args 1 52 53
26 'DBIO::Exception::Server->new: unknown argument(s) '
27 . join(', ', sort keys %args)
28 ) if %args;
29  
30 52 ▶ return bless { msg => $message, %self }, ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
0520
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
31 }
32  
33  
34 5 ▶sub throw {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
35 5 my $class = shift;
36 5 die $class->new(@_);
37 }
38  
39  
40 48 ▶sub sqlstate { $_[0]{sqlstate} }
Subroutine sqlstate: called CC=1 SCAR=0.0
Pod documented
41 10 ▶sub constraint { $_[0]{constraint} }
Subroutine constraint: called CC=1 SCAR=0.0
Pod documented
42 9 ▶sub table { $_[0]{table} }
Subroutine table: called CC=1 SCAR=0.0
Pod documented
43 9 ▶sub detail { $_[0]{detail} }
Subroutine detail: called CC=1 SCAR=0.0
Pod documented
44 12 ▶sub context { $_[0]{context} }
Subroutine context: called CC=1 SCAR=0.0
Pod documented
45  
46  
47 13 ▶sub with_context {
Subroutine with_context: called CC=6 SCAR=18.4
Pod documented
48 13 my ($self, $context, $message) = @_;
49  
50 13 ▶ DBIO::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context and length $context 1 12 13
Condition66%2/3
defined $context and length $context
!ll&&!rl&&r
1012
MC/DC50%1/2
defined $context and length $context
defined $context length $context
Truth table66%2/3
A and B
A= defined $contextB= length $context
ABresult
0X0
100
111
51 'DBIO::Exception::Server->with_context needs a context: BEGIN, COMMIT or ROLLBACK'
52 ) unless defined $context && length $context;
53  
54 12 my %copy = %$self;
55 12 ▶ if (defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $message) 11 1 12
56 11 ▶ DBIO::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless length $message and $message 0 11 11
Condition33%1/3
length $message and $message
!ll&&!rl&&r
0011
MC/DC0%0/2
length $message and $message
length $message $message
Truth table33%1/3
A and B
A= length $messageB= $message
ABresult
0X0
100
111
57 'DBIO::Exception::Server->with_context: the message must be true'
58 ) unless length $message && $message;
59 11 $copy{msg} = $message;
60 }
61 12 $copy{context} = $context;
62  
63 12 return bless \%copy, ref $self;
64 }
65  
66 345 1;
67  
68 __END__
« blib/lib/DBIO/Relationship/HasMany.pm ↑ Summary blib/lib/DBIO/Test/Schema/Encoded.pm »