| 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 = '8.00'; |
|
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::ProductCheck::ISA = __PACKAGE__; |
|
26
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Unauthorized::ISA = __PACKAGE__; |
|
27
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Forbidden::ISA = __PACKAGE__; |
|
28
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Illegal::ISA = __PACKAGE__; |
|
29
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Request::ISA = __PACKAGE__; |
|
30
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Timeout::ISA = __PACKAGE__; |
|
31
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Cxn::ISA = __PACKAGE__; |
|
32
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Serializer::ISA = __PACKAGE__; |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Conflict::ISA |
|
35
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Missing::ISA |
|
38
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::RequestTimeout::ISA |
|
41
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ ); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::ContentLength::ISA |
|
44
|
|
|
|
|
|
|
= ( __PACKAGE__, 'Search::Elasticsearch::Error::Request' ); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::SSL::ISA |
|
47
|
|
|
|
|
|
|
= ( __PACKAGE__, 'Search::Elasticsearch::Error::Cxn' ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::BadGateway::ISA |
|
50
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::Unavailable::ISA |
|
53
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
@Search::Elasticsearch::Error::GatewayTimeout::ISA |
|
56
|
|
|
|
|
|
|
= ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use overload ( |
|
59
|
68
|
|
|
|
|
387
|
'""' => '_stringify', |
|
60
|
|
|
|
|
|
|
'cmp' => '_compare', |
|
61
|
68
|
|
|
68
|
|
40616
|
); |
|
|
68
|
|
|
|
|
35875
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
68
|
|
|
68
|
|
40303
|
use Data::Dumper(); |
|
|
68
|
|
|
|
|
411388
|
|
|
|
68
|
|
|
|
|
46667
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#=================================== |
|
66
|
|
|
|
|
|
|
sub new { |
|
67
|
|
|
|
|
|
|
#=================================== |
|
68
|
120
|
|
|
120
|
0
|
13991
|
my ( $class, $type, $msg, $vars, $caller ) = @_; |
|
69
|
120
|
100
|
|
|
|
369
|
return $type if ref $type; |
|
70
|
93
|
|
100
|
|
|
240
|
$caller ||= 0; |
|
71
|
|
|
|
|
|
|
|
|
72
|
93
|
|
|
|
|
242
|
my $error_class = 'Search::Elasticsearch::Error::' . $type; |
|
73
|
93
|
50
|
|
|
|
229
|
$msg = 'Unknown error' unless defined $msg; |
|
74
|
|
|
|
|
|
|
|
|
75
|
93
|
50
|
|
|
|
250
|
local $DEBUG = 2 if $type eq 'Internal'; |
|
76
|
|
|
|
|
|
|
|
|
77
|
93
|
|
|
|
|
343
|
my $stack = $class->_stack; |
|
78
|
|
|
|
|
|
|
|
|
79
|
93
|
|
|
|
|
569
|
my $self = bless { |
|
80
|
|
|
|
|
|
|
type => $type, |
|
81
|
|
|
|
|
|
|
text => $msg, |
|
82
|
|
|
|
|
|
|
vars => $vars, |
|
83
|
|
|
|
|
|
|
stack => $stack, |
|
84
|
|
|
|
|
|
|
}, $error_class; |
|
85
|
|
|
|
|
|
|
|
|
86
|
93
|
|
|
|
|
667
|
return $self; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#=================================== |
|
90
|
|
|
|
|
|
|
sub is { |
|
91
|
|
|
|
|
|
|
#=================================== |
|
92
|
139
|
|
|
139
|
0
|
220
|
my $self = shift; |
|
93
|
139
|
|
|
|
|
264
|
for (@_) { |
|
94
|
161
|
100
|
|
|
|
944
|
return 1 if $self->isa("Search::Elasticsearch::Error::$_"); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
43
|
|
|
|
|
166
|
return 0; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#=================================== |
|
100
|
|
|
|
|
|
|
sub _stringify { |
|
101
|
|
|
|
|
|
|
#=================================== |
|
102
|
175
|
|
|
175
|
|
1690
|
my $self = shift; |
|
103
|
175
|
|
|
|
|
286
|
local $Data::Dumper::Terse = 1; |
|
104
|
175
|
|
|
|
|
389
|
local $Data::Dumper::Indent = !!$DEBUG; |
|
105
|
|
|
|
|
|
|
|
|
106
|
175
|
100
|
|
|
|
482
|
unless ( $self->{msg} ) { |
|
107
|
78
|
|
|
|
|
167
|
my $stack = $self->{stack}; |
|
108
|
78
|
|
|
|
|
159
|
my $caller = $stack->[0]; |
|
109
|
|
|
|
|
|
|
$self->{msg} = sprintf( "[%s] ** %s, called from sub %s at %s line %d.", |
|
110
|
78
|
|
|
|
|
215
|
$self->{type}, $self->{text}, @{$caller}[ 3, 1, 2 ] ); |
|
|
78
|
|
|
|
|
485
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
78
|
100
|
|
|
|
316
|
if ( $self->{vars} ) { |
|
113
|
|
|
|
|
|
|
$self->{msg} .= sprintf( " With vars: %s\n", |
|
114
|
65
|
|
|
|
|
314
|
Data::Dumper::Dumper $self->{vars} ); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
78
|
50
|
|
|
|
5041
|
if ( @$stack > 1 ) { |
|
118
|
|
|
|
|
|
|
$self->{msg} |
|
119
|
0
|
|
|
|
|
0
|
.= sprintf( "Stacktrace:\n%s\n", $self->stacktrace($stack) ); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
175
|
|
|
|
|
1193
|
return $self->{msg}; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#=================================== |
|
127
|
|
|
|
|
|
|
sub _compare { |
|
128
|
|
|
|
|
|
|
#=================================== |
|
129
|
0
|
|
|
0
|
|
0
|
my ( $self, $other, $swap ) = @_; |
|
130
|
0
|
|
|
|
|
0
|
$self .= ''; |
|
131
|
0
|
0
|
|
|
|
0
|
( $self, $other ) = ( $other, $self ) if $swap; |
|
132
|
0
|
|
|
|
|
0
|
return $self cmp $other; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#=================================== |
|
136
|
|
|
|
|
|
|
sub _stack { |
|
137
|
|
|
|
|
|
|
#=================================== |
|
138
|
93
|
|
|
93
|
|
181
|
my $self = shift; |
|
139
|
93
|
|
50
|
|
|
371
|
my $caller = shift() || 2; |
|
140
|
|
|
|
|
|
|
|
|
141
|
93
|
|
|
|
|
154
|
my @stack; |
|
142
|
93
|
|
|
|
|
308
|
while ( my @caller = caller( ++$caller ) ) { |
|
143
|
183
|
100
|
|
|
|
5155
|
next if $caller[0] eq 'Try::Tiny'; |
|
144
|
|
|
|
|
|
|
|
|
145
|
138
|
50
|
|
|
|
598
|
if ( $caller[3] =~ /^(.+)::__ANON__\[(.+):(\d+)\]$/ ) { |
|
|
|
50
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
0
|
@caller = ( $1, $2, $3, '(ANON)' ); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
elsif ( $caller[1] =~ /^\(eval \d+\)/ ) { |
|
149
|
0
|
|
|
|
|
0
|
$caller[3] = "modified(" . $caller[3] . ")"; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
next |
|
153
|
138
|
50
|
33
|
|
|
568
|
if $caller[0] =~ /^Search::Elasticsearch/ |
|
|
|
|
66
|
|
|
|
|
|
154
|
|
|
|
|
|
|
and ( $DEBUG < 2 or $caller[3] eq 'Try::Tiny::try' ); |
|
155
|
90
|
|
|
|
|
304
|
push @stack, [ @caller[ 0, 1, 2, 3 ] ]; |
|
156
|
90
|
50
|
|
|
|
310
|
last unless $DEBUG > 1; |
|
157
|
|
|
|
|
|
|
} |
|
158
|
93
|
|
|
|
|
316
|
return \@stack; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#=================================== |
|
162
|
|
|
|
|
|
|
sub stacktrace { |
|
163
|
|
|
|
|
|
|
#=================================== |
|
164
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
165
|
0
|
|
0
|
|
|
0
|
my $stack = shift || $self->_stack(); |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
0
|
my $o = sprintf "%s\n%-4s %-50s %-5s %s\n%s\n", |
|
168
|
|
|
|
|
|
|
'-' x 80, '#', 'Package', 'Line', 'Sub-routine', '-' x 80; |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
0
|
my $i = 1; |
|
171
|
0
|
|
|
|
|
0
|
for (@$stack) { |
|
172
|
0
|
|
|
|
|
0
|
$o .= sprintf "%-4d %-50s %4d %s\n", $i++, @{$_}[ 0, 2, 3 ]; |
|
|
0
|
|
|
|
|
0
|
|
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
return $o .= ( '-' x 80 ) . "\n"; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
#=================================== |
|
179
|
|
|
|
|
|
|
sub TO_JSON { |
|
180
|
|
|
|
|
|
|
#=================================== |
|
181
|
1
|
|
|
1
|
0
|
101
|
my $self = shift; |
|
182
|
1
|
|
|
|
|
2
|
return $self->_stringify; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
1; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# ABSTRACT: Errors thrown by Search::Elasticsearch |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
__END__ |