| 1 | 5 | ▶ | use v5.10; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package Neo4j::Error; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Common Neo4j exception representations | ||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | $Neo4j::Error::VERSION = '0.01'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use List::Util 1.33 qw(first none); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Module::Load qw(load); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 5 | my @SOURCES = qw( Server Network Internal Usage ); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 5 | my @KEYS = qw( | |||||||||||||||||||||||||||||||||||||||||
| 14 | as_string | ||||||||||||||||||||||||||||||||||||||||||
| 15 | category | ||||||||||||||||||||||||||||||||||||||||||
| 16 | classification | ||||||||||||||||||||||||||||||||||||||||||
| 17 | code | ||||||||||||||||||||||||||||||||||||||||||
| 18 | is_retryable | ||||||||||||||||||||||||||||||||||||||||||
| 19 | message | ||||||||||||||||||||||||||||||||||||||||||
| 20 | raw | ||||||||||||||||||||||||||||||||||||||||||
| 21 | related | ||||||||||||||||||||||||||||||||||||||||||
| 22 | source | ||||||||||||||||||||||||||||||||||||||||||
| 23 | title | ||||||||||||||||||||||||||||||||||||||||||
| 24 | trace | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | sub _croak { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 18 | ▶ | require Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 18 | Carp::croak(@_); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 53 | ▶ | my ($class, $source, $info, @extra) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 53 | ▶ | _croak "Call as instance method unsupported for %s->new()", __PACKAGE__ if ref $class ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 52 | ▶ | _croak sprintf "Source param required for %s->new()", __PACKAGE__ unless $source && ref $source eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$source and ref $source eq ""
MC/DC100%2/2
$source and ref $source eq ""
$source
ref $source eq ""
Truth table100%3/3
A and B
A= $sourceB= ref $source eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 50 | ▶ | if ($class eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 42 | ▶ | $class = first { $_ eq $source } @SOURCES; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 42 | ▶ | _croak sprintf "Source '%s' is unsupported for %s->new()", $source, __PACKAGE__ unless $class; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 38 | $class = __PACKAGE__ . "::$class"; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 38 | load $class; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | else { # subclass | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | ▶ | _croak sprintf "Class %s fails to implement source()", $class unless $class->can('source'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | _croak sprintf "Ambiguous source %s for %s", $source, $class if $class->source ne $source; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 44 | ▶ | if ($info && ref $info eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$info and ref $info eq ""
MC/DC100%2/2
$info and ref $info eq ""
$info
ref $info eq ""
Truth table100%3/3
A and B
A= $infoB= ref $info eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | $info = { as_string => '' . $info }; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | elsif (ref $info ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | _croak sprintf "Hashref or string required for %s->new()", $class; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 42 | ▶ | _croak "Too many arguments for $class->new()" if @extra; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 40 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 40 | $self->{$_} = $info->{$_} for @KEYS; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 40 | require Devel::StackTrace; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 40 | ▶ | my $trace_config = $info->{trace} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$info->{"trace"} // {}
MC/DC100%1/1
$info->{"trace"} // {}
$info->{"trace"}
Truth table100%2/2
A
A= $info->{"trace"}
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 40 | $trace_config->{skip_frames}++; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 40 | ▶ | $trace_config->{message} //= $self->as_string; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$trace_config->{"message"} //= $self->as_string
MC/DC100%2/2
$trace_config->{"message"} //= $self->as_string
$trace_config->{"message"}
$self->as_string
Truth table100%3/3
A //= B
A= $trace_config->{"message"}B= $self->as_string
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 40 | $self->{trace} = Devel::StackTrace->new(%$trace_config); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 40 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | sub append_new { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 12 | ▶ | my ($self, $source, $related, @extra) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append_new: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 12 | ▶ | _croak sprintf "Source param required for %s->append_new()", __PACKAGE__ unless $source && ref $source eq ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$source and ref $source eq ""
MC/DC100%2/2
$source and ref $source eq ""
$source
ref $source eq ""
Truth table100%3/3
A and B
A= $sourceB= ref $source eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | ▶ | _croak sprintf "Ambiguous source %s for %s", $source, $self if ref $self eq '' && $self->can('source') && $self->source ne $source; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
ref $self eq "" and $self->can("source") and $self->source ne $source
ref $self eq "" and $self->can("source")
MC/DC100%3/3
ref $self eq "" and $self->can("source") and $self->source ne $source
ref $self eq ""
$self->can("source")
$self->source ne $source
Truth table100%4/4
A and B and C
A= ref $self eq ""B= $self->can("source")C= $self->source ne $source
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 9 | ▶ | if ($related && ref $related eq '') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$related and ref $related eq ""
MC/DC100%2/2
$related and ref $related eq ""
$related
ref $related eq ""
Truth table100%3/3
A and B
A= $relatedB= ref $related eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $related = { as_string => '' . $related }; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif (ref $related ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | _croak sprintf "Hashref or string required for %s->append_new()", __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 7 | ▶ | my $class = ref $self eq '' ? $self : __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 7 | $related->{trace}{skip_frames}++; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | $related = $class->new($source => $related, @extra); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ▶ | return $related if ref $self eq ''; # if called as class method, behave just like new() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my $tail = $self; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | $tail = $tail->{related} while $tail->{related}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | $tail->{related} = $related; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 61 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 61 | my $str = $self->{as_string}; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 61 | ▶ | return $str if defined $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 29 | my $code = $self->code; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 29 | my $message = $self->message; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 29 | ▶ | $str = sprintf "%s: %s", $code, $message if $code && $message; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$code and $message
MC/DC100%2/2
$code and $message
$code
$message
Truth table100%3/3
A and B
A= $codeB= $message
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 29 | ▶ | $str = sprintf "%s %s", ref $self, $code if $code && ! $message; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$code and not $message
MC/DC100%2/2
$code and not $message
$code
not $message
Truth table100%3/3
A and not(B)
A= $codeB= not $message
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 29 | ▶ | $str = sprintf "%s", $message if ! $code && $message; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $code and $message
MC/DC100%2/2
not $code and $message
not $code
$message
Truth table100%3/3
not(A) and B
A= not $codeB= $message
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 29 | ▶ | $str = $self->trace unless $str; # last resort | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 29 | return $self->{as_string} = $str; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 18 | ▶ | sub message { shift->{message} // '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
+(shift())->{"message"} // ""
MC/DC100%1/1
+(shift())->{"message"} // ""
+(shift())->{"message"}
Truth table100%2/2
A
A= +(shift())->{"message"}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 18 | ▶ | sub code { shift->{code} // '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
+(shift())->{"code"} // ""
MC/DC100%1/1
+(shift())->{"code"} // ""
+(shift())->{"code"}
Truth table100%2/2
A
A= +(shift())->{"code"}
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | ▶ | sub classification { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
classification: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | sub category { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
category: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | sub title { '' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | sub is_retryable { !!0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_retryable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | ▶ | sub related { shift->{related} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
related: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | sub raw { shift->{raw} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
raw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 21 | ▶ | sub trace { shift->{trace} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | __END__ | ||||||||||||||||||||||||||||||||||||||||||