line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Licensed to Elasticsearch B.V. under one or more contributor |
2
|
|
|
|
|
|
|
# license agreements. See the NOTICE file distributed with |
3
|
|
|
|
|
|
|
# this work for additional information regarding copyright |
4
|
|
|
|
|
|
|
# ownership. Elasticsearch B.V. licenses this file to you under |
5
|
|
|
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may |
6
|
|
|
|
|
|
|
# not use this file except in compliance with the License. |
7
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, |
12
|
|
|
|
|
|
|
# software distributed under the License is distributed on an |
13
|
|
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14
|
|
|
|
|
|
|
# KIND, either express or implied. See the License for the |
15
|
|
|
|
|
|
|
# specific language governing permissions and limitations |
16
|
|
|
|
|
|
|
# under the License. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Search::Elasticsearch::Error; |
19
|
|
|
|
|
|
|
$Search::Elasticsearch::Error::VERSION = '7.717'; |
20
|
|
|
|
|
|
|
our $DEBUG = 0; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Internal::ISA = __PACKAGE__; |
23
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Param::ISA = __PACKAGE__; |
24
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::NoNodes::ISA = __PACKAGE__; |
25
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Unauthorized::ISA = __PACKAGE__; |
26
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Forbidden::ISA = __PACKAGE__; |
27
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Illegal::ISA = __PACKAGE__; |
28
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Request::ISA = __PACKAGE__; |
29
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Timeout::ISA = __PACKAGE__; |
30
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Cxn::ISA = __PACKAGE__; |
31
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Serializer::ISA = __PACKAGE__; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Conflict::ISA |
34
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Missing::ISA |
37
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::RequestTimeout::ISA |
40
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::ContentLength::ISA |
43
|
|
|
|
|
|
|
= ( __PACKAGE__, 'Search::Elasticsearch::Error::Request' ); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::SSL::ISA |
46
|
|
|
|
|
|
|
= ( __PACKAGE__, 'Search::Elasticsearch::Error::Cxn' ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::BadGateway::ISA |
49
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Unavailable::ISA |
52
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::GatewayTimeout::ISA |
55
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
use overload ( |
58
|
68
|
|
|
|
|
358
|
'""' => '_stringify', |
59
|
|
|
|
|
|
|
'cmp' => '_compare', |
60
|
68
|
|
|
68
|
|
32883
|
); |
|
68
|
|
|
|
|
29178
|
|
61
|
|
|
|
|
|
|
|
62
|
68
|
|
|
68
|
|
33308
|
use Data::Dumper(); |
|
68
|
|
|
|
|
336695
|
|
|
68
|
|
|
|
|
38565
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#=================================== |
65
|
|
|
|
|
|
|
sub new { |
66
|
|
|
|
|
|
|
#=================================== |
67
|
119
|
|
|
119
|
0
|
12469
|
my ( $class, $type, $msg, $vars, $caller ) = @_; |
68
|
119
|
100
|
|
|
|
299
|
return $type if ref $type; |
69
|
92
|
|
100
|
|
|
251
|
$caller ||= 0; |
70
|
|
|
|
|
|
|
|
71
|
92
|
|
|
|
|
222
|
my $error_class = 'Search::Elasticsearch::Error::' . $type; |
72
|
92
|
50
|
|
|
|
233
|
$msg = 'Unknown error' unless defined $msg; |
73
|
|
|
|
|
|
|
|
74
|
92
|
50
|
|
|
|
225
|
local $DEBUG = 2 if $type eq 'Internal'; |
75
|
|
|
|
|
|
|
|
76
|
92
|
|
|
|
|
287
|
my $stack = $class->_stack; |
77
|
|
|
|
|
|
|
|
78
|
92
|
|
|
|
|
492
|
my $self = bless { |
79
|
|
|
|
|
|
|
type => $type, |
80
|
|
|
|
|
|
|
text => $msg, |
81
|
|
|
|
|
|
|
vars => $vars, |
82
|
|
|
|
|
|
|
stack => $stack, |
83
|
|
|
|
|
|
|
}, $error_class; |
84
|
|
|
|
|
|
|
|
85
|
92
|
|
|
|
|
582
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#=================================== |
89
|
|
|
|
|
|
|
sub is { |
90
|
|
|
|
|
|
|
#=================================== |
91
|
139
|
|
|
139
|
0
|
180
|
my $self = shift; |
92
|
139
|
|
|
|
|
240
|
for (@_) { |
93
|
161
|
100
|
|
|
|
764
|
return 1 if $self->isa("Search::Elasticsearch::Error::$_"); |
94
|
|
|
|
|
|
|
} |
95
|
43
|
|
|
|
|
141
|
return 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#=================================== |
99
|
|
|
|
|
|
|
sub _stringify { |
100
|
|
|
|
|
|
|
#=================================== |
101
|
174
|
|
|
174
|
|
1448
|
my $self = shift; |
102
|
174
|
|
|
|
|
249
|
local $Data::Dumper::Terse = 1; |
103
|
174
|
|
|
|
|
307
|
local $Data::Dumper::Indent = !!$DEBUG; |
104
|
|
|
|
|
|
|
|
105
|
174
|
100
|
|
|
|
398
|
unless ( $self->{msg} ) { |
106
|
77
|
|
|
|
|
131
|
my $stack = $self->{stack}; |
107
|
77
|
|
|
|
|
131
|
my $caller = $stack->[0]; |
108
|
|
|
|
|
|
|
$self->{msg} = sprintf( "[%s] ** %s, called from sub %s at %s line %d.", |
109
|
77
|
|
|
|
|
170
|
$self->{type}, $self->{text}, @{$caller}[ 3, 1, 2 ] ); |
|
77
|
|
|
|
|
407
|
|
110
|
|
|
|
|
|
|
|
111
|
77
|
100
|
|
|
|
225
|
if ( $self->{vars} ) { |
112
|
|
|
|
|
|
|
$self->{msg} .= sprintf( " With vars: %s\n", |
113
|
65
|
|
|
|
|
274
|
Data::Dumper::Dumper $self->{vars} ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
77
|
50
|
|
|
|
4146
|
if ( @$stack > 1 ) { |
117
|
|
|
|
|
|
|
$self->{msg} |
118
|
0
|
|
|
|
|
0
|
.= sprintf( "Stacktrace:\n%s\n", $self->stacktrace($stack) ); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
174
|
|
|
|
|
968
|
return $self->{msg}; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#=================================== |
126
|
|
|
|
|
|
|
sub _compare { |
127
|
|
|
|
|
|
|
#=================================== |
128
|
0
|
|
|
0
|
|
0
|
my ( $self, $other, $swap ) = @_; |
129
|
0
|
|
|
|
|
0
|
$self .= ''; |
130
|
0
|
0
|
|
|
|
0
|
( $self, $other ) = ( $other, $self ) if $swap; |
131
|
0
|
|
|
|
|
0
|
return $self cmp $other; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#=================================== |
135
|
|
|
|
|
|
|
sub _stack { |
136
|
|
|
|
|
|
|
#=================================== |
137
|
92
|
|
|
92
|
|
149
|
my $self = shift; |
138
|
92
|
|
50
|
|
|
310
|
my $caller = shift() || 2; |
139
|
|
|
|
|
|
|
|
140
|
92
|
|
|
|
|
155
|
my @stack; |
141
|
92
|
|
|
|
|
282
|
while ( my @caller = caller( ++$caller ) ) { |
142
|
182
|
100
|
|
|
|
4257
|
next if $caller[0] eq 'Try::Tiny'; |
143
|
|
|
|
|
|
|
|
144
|
137
|
50
|
|
|
|
488
|
if ( $caller[3] =~ /^(.+)::__ANON__\[(.+):(\d+)\]$/ ) { |
|
|
50
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
@caller = ( $1, $2, $3, '(ANON)' ); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
elsif ( $caller[1] =~ /^\(eval \d+\)/ ) { |
148
|
0
|
|
|
|
|
0
|
$caller[3] = "modified(" . $caller[3] . ")"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
next |
152
|
137
|
50
|
33
|
|
|
483
|
if $caller[0] =~ /^Search::Elasticsearch/ |
|
|
|
66
|
|
|
|
|
153
|
|
|
|
|
|
|
and ( $DEBUG < 2 or $caller[3] eq 'Try::Tiny::try' ); |
154
|
89
|
|
|
|
|
270
|
push @stack, [ @caller[ 0, 1, 2, 3 ] ]; |
155
|
89
|
50
|
|
|
|
261
|
last unless $DEBUG > 1; |
156
|
|
|
|
|
|
|
} |
157
|
92
|
|
|
|
|
247
|
return \@stack; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#=================================== |
161
|
|
|
|
|
|
|
sub stacktrace { |
162
|
|
|
|
|
|
|
#=================================== |
163
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
164
|
0
|
|
0
|
|
|
0
|
my $stack = shift || $self->_stack(); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
0
|
my $o = sprintf "%s\n%-4s %-50s %-5s %s\n%s\n", |
167
|
|
|
|
|
|
|
'-' x 80, '#', 'Package', 'Line', 'Sub-routine', '-' x 80; |
168
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
my $i = 1; |
170
|
0
|
|
|
|
|
0
|
for (@$stack) { |
171
|
0
|
|
|
|
|
0
|
$o .= sprintf "%-4d %-50s %4d %s\n", $i++, @{$_}[ 0, 2, 3 ]; |
|
0
|
|
|
|
|
0
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
0
|
return $o .= ( '-' x 80 ) . "\n"; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#=================================== |
178
|
|
|
|
|
|
|
sub TO_JSON { |
179
|
|
|
|
|
|
|
#=================================== |
180
|
1
|
|
|
1
|
0
|
88
|
my $self = shift; |
181
|
1
|
|
|
|
|
2
|
return $self->_stringify; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
1; |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# ABSTRACT: Errors thrown by Search::Elasticsearch |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
__END__ |