line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.014; |
3
|
21
|
|
|
21
|
|
462
|
use strict; |
|
21
|
|
|
|
|
66
|
|
4
|
21
|
|
|
21
|
|
104
|
use warnings; |
|
21
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
483
|
|
5
|
21
|
|
|
21
|
|
95
|
use Moo; |
|
21
|
|
|
|
|
36
|
|
|
21
|
|
|
|
|
632
|
|
6
|
21
|
|
|
21
|
|
548
|
use Types::Standard -all; |
|
21
|
|
|
|
|
7188
|
|
|
21
|
|
|
|
|
179
|
|
7
|
21
|
|
|
21
|
|
8607
|
use GraphQL::Type::Library -all; |
|
21
|
|
|
|
|
58
|
|
|
21
|
|
|
|
|
173
|
|
8
|
21
|
|
|
21
|
|
837380
|
use GraphQL::MaybeTypeCheck; |
|
21
|
|
|
|
|
63
|
|
|
21
|
|
|
|
|
217
|
|
9
|
21
|
|
|
21
|
|
252243
|
use GraphQL::Debug qw(_debug); |
|
21
|
|
|
|
|
51
|
|
|
21
|
|
|
|
|
183
|
|
10
|
21
|
|
|
21
|
|
461
|
|
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
1562
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
14
|
21
|
|
|
21
|
|
126
|
my %NONENUM = map { ($_ => 1) } qw(original_error); |
|
21
|
|
|
|
|
40
|
|
|
21
|
|
|
|
|
1974
|
|
15
|
|
|
|
|
|
|
use overload '""' => 'to_string'; |
16
|
21
|
|
|
21
|
|
130
|
|
|
21
|
|
|
|
|
42
|
|
|
21
|
|
|
|
|
210
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
GraphQL::Error - GraphQL error object |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use GraphQL::Error; |
24
|
|
|
|
|
|
|
die GraphQL::Error->new(message => 'Something is not right...'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Class implementing GraphQL error object. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 message |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has message => (is => 'ro', isa => Str, required => 1); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 original_error |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
If there is an original error to be preserved. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has original_error => (is => 'ro', isa => Any); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 locations |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Array-ref of L<GraphQL::Type::Library/DocumentLocation>s. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has locations => (is => 'ro', isa => ArrayRef[DocumentLocation]); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 path |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Array-ref of L<GraphQL::Type::Library/StrNameValid>s or C<Int>s describing |
57
|
|
|
|
|
|
|
the path from the top operation (being either fields, or a List offset). |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has path => (is => 'ro', isa => ArrayRef[StrNameValid | Int]); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 extensions |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Hash-ref of L<GraphQL::Type::Library/JSONable>s providing additional |
66
|
|
|
|
|
|
|
information. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
has extensions => (is => 'ro', isa => Optional[HashRef[JSONable]]); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 is |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Is the supplied scalar an error object? |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
method is(Any $item) :ReturnType(Bool) { ref $item eq __PACKAGE__ } |
81
|
21
|
50
|
|
21
|
1
|
6733
|
|
|
21
|
50
|
|
3957
|
|
40
|
|
|
21
|
50
|
|
|
|
182
|
|
|
3957
|
|
|
|
|
6324
|
|
|
3957
|
|
|
|
|
5537
|
|
|
3957
|
|
|
|
|
4742
|
|
|
3957
|
|
|
|
|
5353
|
|
|
3957
|
|
|
|
|
6039
|
|
|
3957
|
|
|
|
|
19305
|
|
|
3957
|
|
|
|
|
9803
|
|
82
|
|
|
|
|
|
|
=head2 coerce |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
If supplied scalar is an error object, return. If not, return one with |
85
|
|
|
|
|
|
|
it as message. If an object, message will be stringified version of that, |
86
|
|
|
|
|
|
|
it will be preserved as C<original_error>. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
method coerce( |
91
|
|
|
|
|
|
|
Any $item |
92
|
|
|
|
|
|
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
93
|
367
|
50
|
|
367
|
1
|
799
|
DEBUG and _debug('Error.coerce', $item); |
|
367
|
50
|
|
|
|
614
|
|
|
367
|
50
|
|
|
|
454
|
|
|
367
|
|
|
|
|
542
|
|
|
367
|
|
|
|
|
762
|
|
|
367
|
|
|
|
|
2123
|
|
94
|
367
|
|
|
|
|
379
|
return $item if __PACKAGE__->is($item); |
95
|
367
|
100
|
|
|
|
703
|
$item ||= 'Unknown error'; |
96
|
85
|
|
50
|
|
|
241
|
!is_Str($item) |
97
|
85
|
100
|
|
|
|
284
|
? $self->new(message => $item.'', original_error => $item) |
98
|
|
|
|
|
|
|
: $self->new(message => $item); |
99
|
|
|
|
|
|
|
} |
100
|
21
|
|
|
21
|
|
11523
|
|
|
21
|
|
|
|
|
50
|
|
|
21
|
|
|
|
|
81
|
|
101
|
|
|
|
|
|
|
=head2 but |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns a copy of the error object, but with the given properties (as |
104
|
|
|
|
|
|
|
with a C<new> method, not coincidentally) overriding the existing ones. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $self = shift; |
109
|
|
|
|
|
|
|
$self->new(%$self, @_); |
110
|
76
|
|
|
76
|
1
|
133
|
} |
111
|
76
|
|
|
|
|
1503
|
|
112
|
21
|
|
|
21
|
|
5697
|
=head2 to_string |
|
21
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
74
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Converts to string. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
method to_string(@ignore) :ReturnType(Str) { |
119
|
|
|
|
|
|
|
$self->message; |
120
|
237
|
50
|
|
237
|
1
|
8873
|
} |
|
237
|
|
|
|
|
312
|
|
|
237
|
|
|
|
|
394
|
|
|
237
|
|
|
|
|
257
|
|
121
|
237
|
|
|
|
|
941
|
|
122
|
21
|
|
|
21
|
|
5994
|
=head2 to_json |
|
21
|
|
|
|
|
44
|
|
|
21
|
|
|
|
|
95
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Converts to a JSON-able hash, in the format to send back as a member of |
125
|
|
|
|
|
|
|
the C<errors> array in the results. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
method to_json() :ReturnType(HashRef) { |
130
|
|
|
|
|
|
|
+{ map { ($_ => $self->{$_}) } grep !$NONENUM{$_}, keys %$self }; |
131
|
99
|
50
|
|
99
|
1
|
256
|
} |
|
99
|
50
|
|
|
|
253
|
|
|
99
|
|
|
|
|
152
|
|
|
99
|
|
|
|
|
124
|
|
132
|
99
|
|
|
|
|
385
|
|
|
251
|
|
|
|
|
1115
|
|
133
|
21
|
|
|
21
|
|
6985
|
__PACKAGE__->meta->make_immutable(); |
|
21
|
|
|
|
|
47
|
|
|
21
|
|
|
|
|
74
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |