| 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
Condition83%5/6
defined $message and length $message and $message
defined $message and length $message
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $context and length $context
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 11 | ▶ | DBIO::Exception->throw( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
length $message and $message
MC/DC0%0/2
length $message and $message
length $message
$message
Truth table33%1/3
A and B
A= length $messageB= $message
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||