line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GraphQL::Error; |
2
|
|
|
|
|
|
|
|
3
|
21
|
|
|
21
|
|
513
|
use 5.014; |
|
21
|
|
|
|
|
74
|
|
4
|
21
|
|
|
21
|
|
118
|
use strict; |
|
21
|
|
|
|
|
39
|
|
|
21
|
|
|
|
|
504
|
|
5
|
21
|
|
|
21
|
|
130
|
use warnings; |
|
21
|
|
|
|
|
37
|
|
|
21
|
|
|
|
|
744
|
|
6
|
21
|
|
|
21
|
|
617
|
use Moo; |
|
21
|
|
|
|
|
8522
|
|
|
21
|
|
|
|
|
228
|
|
7
|
21
|
|
|
21
|
|
10025
|
use Types::Standard -all; |
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
238
|
|
8
|
21
|
|
|
21
|
|
1004634
|
use GraphQL::Type::Library -all; |
|
21
|
|
|
|
|
60
|
|
|
21
|
|
|
|
|
233
|
|
9
|
21
|
|
|
21
|
|
296454
|
use GraphQL::MaybeTypeCheck; |
|
21
|
|
|
|
|
53
|
|
|
21
|
|
|
|
|
189
|
|
10
|
21
|
|
|
21
|
|
558
|
use GraphQL::Debug qw(_debug); |
|
21
|
|
|
|
|
53
|
|
|
21
|
|
|
|
|
1879
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
13
|
|
|
|
|
|
|
|
14
|
21
|
|
|
21
|
|
142
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
|
21
|
|
|
|
|
39
|
|
|
21
|
|
|
|
|
2137
|
|
15
|
|
|
|
|
|
|
my %NONENUM = map { ($_ => 1) } qw(original_error); |
16
|
21
|
|
|
21
|
|
135
|
use overload '""' => 'to_string'; |
|
21
|
|
|
|
|
48
|
|
|
21
|
|
|
|
|
223
|
|
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
|
7511
|
method is(Any $item) :ReturnType(Bool) { ref $item eq __PACKAGE__ } |
|
21
|
50
|
|
3957
|
|
49
|
|
|
21
|
50
|
|
|
|
195
|
|
|
3957
|
|
|
|
|
7719
|
|
|
3957
|
|
|
|
|
6967
|
|
|
3957
|
|
|
|
|
5638
|
|
|
3957
|
|
|
|
|
6466
|
|
|
3957
|
|
|
|
|
7430
|
|
|
3957
|
|
|
|
|
23379
|
|
|
3957
|
|
|
|
|
11776
|
|
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
|
1081
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
|
367
|
50
|
|
|
|
740
|
|
|
367
|
50
|
|
|
|
546
|
|
|
367
|
|
|
|
|
614
|
|
|
367
|
|
|
|
|
801
|
|
|
367
|
|
|
|
|
2558
|
|
94
|
367
|
|
|
|
|
555
|
DEBUG and _debug('Error.coerce', $item); |
95
|
367
|
100
|
|
|
|
769
|
return $item if __PACKAGE__->is($item); |
96
|
85
|
|
50
|
|
|
245
|
$item ||= 'Unknown error'; |
97
|
85
|
100
|
|
|
|
302
|
!is_Str($item) |
98
|
|
|
|
|
|
|
? $self->new(message => $item.'', original_error => $item) |
99
|
|
|
|
|
|
|
: $self->new(message => $item); |
100
|
21
|
|
|
21
|
|
12708
|
} |
|
21
|
|
|
|
|
51
|
|
|
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
|
160
|
my $self = shift; |
111
|
76
|
|
|
|
|
1780
|
$self->new(%$self, @_); |
112
|
21
|
|
|
21
|
|
6474
|
} |
|
21
|
|
|
|
|
47
|
|
|
21
|
|
|
|
|
100
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 to_string |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Converts to string. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
|
120
|
237
|
50
|
|
237
|
1
|
7608
|
method to_string(@ignore) :ReturnType(Str) { |
|
237
|
|
|
|
|
354
|
|
|
237
|
|
|
|
|
490
|
|
|
237
|
|
|
|
|
306
|
|
121
|
237
|
|
|
|
|
2506
|
$self->message; |
122
|
21
|
|
|
21
|
|
6958
|
} |
|
21
|
|
|
|
|
52
|
|
|
21
|
|
|
|
|
99
|
|
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
|
358
|
method to_json() :ReturnType(HashRef) { |
|
99
|
50
|
|
|
|
297
|
|
|
99
|
|
|
|
|
193
|
|
|
99
|
|
|
|
|
157
|
|
132
|
99
|
|
|
|
|
469
|
+{ map { ($_ => $self->{$_}) } grep !$NONENUM{$_}, keys %$self }; |
|
251
|
|
|
|
|
1280
|
|
133
|
21
|
|
|
21
|
|
8010
|
} |
|
21
|
|
|
|
|
49
|
|
|
21
|
|
|
|
|
86
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |