line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GraphQL::Error; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
583
|
use 5.014; |
|
21
|
|
|
|
|
83
|
|
4
|
21
|
|
|
21
|
|
109
|
use strict; |
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
600
|
|
5
|
21
|
|
|
21
|
|
121
|
use warnings; |
|
21
|
|
|
|
|
38
|
|
|
21
|
|
|
|
|
755
|
|
6
|
21
|
|
|
21
|
|
608
|
use Moo; |
|
21
|
|
|
|
|
7476
|
|
|
21
|
|
|
|
|
201
|
|
7
|
21
|
|
|
21
|
|
9533
|
use Types::Standard -all; |
|
21
|
|
|
|
|
58
|
|
|
21
|
|
|
|
|
223
|
|
8
|
21
|
|
|
21
|
|
921915
|
use GraphQL::Type::Library -all; |
|
21
|
|
|
|
|
53
|
|
|
21
|
|
|
|
|
248
|
|
9
|
21
|
|
|
21
|
|
273579
|
use GraphQL::MaybeTypeCheck; |
|
21
|
|
|
|
|
58
|
|
|
21
|
|
|
|
|
218
|
|
10
|
21
|
|
|
21
|
|
607
|
use GraphQL::Debug qw(_debug); |
|
21
|
|
|
|
|
48
|
|
|
21
|
|
|
|
|
1897
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
21
|
|
|
21
|
|
138
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
|
21
|
|
|
|
|
62
|
|
|
21
|
|
|
|
|
2304
|
|
15
|
|
|
|
|
|
|
my %NONENUM = map { ($_ => 1) } qw(original_error); |
16
|
21
|
|
|
21
|
|
139
|
use overload '""' => 'to_string'; |
|
21
|
|
|
|
|
49
|
|
|
21
|
|
|
|
|
208
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
GraphQL::Error - GraphQL error object |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use GraphQL::Error; |
25
|
|
|
|
|
|
|
die GraphQL::Error->new(message => 'Something is not right...'); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Class implementing GraphQL error object. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 message |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has message => (is => 'ro', isa => Str, required => 1); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 original_error |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
If there is an original error to be preserved. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has original_error => (is => 'ro', isa => Any); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 locations |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Array-ref of L<GraphQL::Type::Library/DocumentLocation>s. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has locations => (is => 'ro', isa => ArrayRef[DocumentLocation]); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 path |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Array-ref of L<GraphQL::Type::Library/StrNameValid>s or C<Int>s describing |
58
|
|
|
|
|
|
|
the path from the top operation (being either fields, or a List offset). |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has path => (is => 'ro', isa => ArrayRef[StrNameValid | Int]); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 extensions |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Hash-ref of L<GraphQL::Type::Library/JSONable>s providing additional |
67
|
|
|
|
|
|
|
information. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has extensions => (is => 'ro', isa => Optional[HashRef[JSONable]]); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 is |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Is the supplied scalar an error object? |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
21
|
50
|
|
21
|
1
|
7415
|
method is(Any $item) :ReturnType(Bool) { ref $item eq __PACKAGE__ } |
|
21
|
50
|
|
3957
|
|
49
|
|
|
21
|
50
|
|
|
|
179
|
|
|
3957
|
|
|
|
|
6583
|
|
|
3957
|
|
|
|
|
6192
|
|
|
3957
|
|
|
|
|
5176
|
|
|
3957
|
|
|
|
|
5636
|
|
|
3957
|
|
|
|
|
6352
|
|
|
3957
|
|
|
|
|
20571
|
|
|
3957
|
|
|
|
|
10363
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 coerce |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
If supplied scalar is an error object, return. If not, return one with |
86
|
|
|
|
|
|
|
it as message. If an object, message will be stringified version of that, |
87
|
|
|
|
|
|
|
it will be preserved as C<original_error>. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
method coerce( |
92
|
|
|
|
|
|
|
Any $item |
93
|
367
|
50
|
|
367
|
1
|
1021
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
|
367
|
50
|
|
|
|
752
|
|
|
367
|
50
|
|
|
|
567
|
|
|
367
|
|
|
|
|
609
|
|
|
367
|
|
|
|
|
795
|
|
|
367
|
|
|
|
|
2434
|
|
94
|
367
|
|
|
|
|
446
|
DEBUG and _debug('Error.coerce', $item); |
95
|
367
|
100
|
|
|
|
846
|
return $item if __PACKAGE__->is($item); |
96
|
85
|
|
50
|
|
|
237
|
$item ||= 'Unknown error'; |
97
|
85
|
100
|
|
|
|
291
|
!is_Str($item) |
98
|
|
|
|
|
|
|
? $self->new(message => $item.'', original_error => $item) |
99
|
|
|
|
|
|
|
: $self->new(message => $item); |
100
|
21
|
|
|
21
|
|
12659
|
} |
|
21
|
|
|
|
|
48
|
|
|
21
|
|
|
|
|
93
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 but |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Returns a copy of the error object, but with the given properties (as |
105
|
|
|
|
|
|
|
with a C<new> method, not coincidentally) overriding the existing ones. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub but :ReturnType(InstanceOf[__PACKAGE__]) { |
110
|
76
|
|
|
76
|
1
|
173
|
my $self = shift; |
111
|
76
|
|
|
|
|
1786
|
$self->new(%$self, @_); |
112
|
21
|
|
|
21
|
|
6194
|
} |
|
21
|
|
|
|
|
46
|
|
|
21
|
|
|
|
|
85
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 to_string |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Converts to string. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
237
|
50
|
|
237
|
1
|
7521
|
method to_string(@ignore) :ReturnType(Str) { |
|
237
|
|
|
|
|
364
|
|
|
237
|
|
|
|
|
434
|
|
|
237
|
|
|
|
|
288
|
|
121
|
237
|
|
|
|
|
1031
|
$self->message; |
122
|
21
|
|
|
21
|
|
6522
|
} |
|
21
|
|
|
|
|
54
|
|
|
21
|
|
|
|
|
89
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 to_json |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Converts to a JSON-able hash, in the format to send back as a member of |
127
|
|
|
|
|
|
|
the C<errors> array in the results. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
99
|
50
|
|
99
|
1
|
312
|
method to_json() :ReturnType(HashRef) { |
|
99
|
50
|
|
|
|
265
|
|
|
99
|
|
|
|
|
187
|
|
|
99
|
|
|
|
|
158
|
|
132
|
99
|
|
|
|
|
452
|
+{ map { ($_ => $self->{$_}) } grep !$NONENUM{$_}, keys %$self }; |
|
251
|
|
|
|
|
1260
|
|
133
|
21
|
|
|
21
|
|
7742
|
} |
|
21
|
|
|
|
|
58
|
|
|
21
|
|
|
|
|
106
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |