line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Record::Serialize::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Error objects |
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
243
|
use v5.12; |
|
17
|
|
|
|
|
62
|
|
6
|
17
|
|
|
17
|
|
88
|
use strict; |
|
17
|
|
|
|
|
36
|
|
|
17
|
|
|
|
|
319
|
|
7
|
17
|
|
|
17
|
|
84
|
use warnings; |
|
17
|
|
|
|
|
35
|
|
|
17
|
|
|
|
|
863
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.05'; |
10
|
|
|
|
|
|
|
|
11
|
17
|
|
|
17
|
|
7185
|
use Exporter::Shiny qw( error ); |
|
17
|
|
|
|
|
84950
|
|
|
17
|
|
|
|
|
126
|
|
12
|
|
|
|
|
|
|
|
13
|
17
|
|
|
|
|
175
|
use custom::failures ( qw[ |
14
|
|
|
|
|
|
|
attribute::value |
15
|
|
|
|
|
|
|
method::stub |
16
|
17
|
|
|
17
|
|
8774
|
] ); |
|
17
|
|
|
|
|
92698
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _exporter_validate_opts { |
29
|
72
|
|
|
72
|
|
14490
|
my $class = shift; |
30
|
|
|
|
|
|
|
|
31
|
72
|
|
|
|
|
230
|
my ( $globals ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
72
|
100
|
|
|
|
320
|
if ( defined $globals->{errors} ) { |
34
|
|
|
|
|
|
|
|
35
|
55
|
|
|
|
|
133
|
my @classes = @{ delete $globals->{errors}; }; |
|
55
|
|
|
|
|
237
|
|
36
|
|
|
|
|
|
|
|
37
|
55
|
50
|
|
|
|
275
|
if ( @classes ) { |
38
|
55
|
|
|
|
|
296
|
$_ = _resolve_class( $_, $globals->{into} ) foreach @classes; |
39
|
55
|
|
|
|
|
643
|
custom::failures->import( @classes ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
72
|
|
|
|
|
20354
|
$class->SUPER::_exporter_validate_opts( @_ ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub error { |
59
|
9
|
|
|
9
|
1
|
26
|
my $class = shift; |
60
|
9
|
|
|
|
|
42
|
_resolve_class( $class, scalar caller(), __PACKAGE__ )->throw( @_ ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _resolve_class { |
64
|
95
|
|
|
95
|
|
279
|
my ( $class, $caller, @prefix ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return join( |
67
|
|
|
|
|
|
|
q{::}, @prefix, |
68
|
95
|
|
|
|
|
203
|
do { |
69
|
95
|
100
|
|
|
|
668
|
if ( $class =~ /^::(.*)/ ) { |
|
|
100
|
|
|
|
|
|
70
|
29
|
|
|
|
|
138
|
$1; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
elsif ( $caller =~ /Data::Record::Serialize::(.*)/ ) { |
73
|
64
|
|
|
|
|
505
|
$1 . q{::} . $class; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else { |
76
|
2
|
|
|
|
|
49
|
$class; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# This file is part of Data-Record-Serialize |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
# This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
88
|
|
|
|
|
|
|
# |
89
|
|
|
|
|
|
|
# This is free software, licensed under: |
90
|
|
|
|
|
|
|
# |
91
|
|
|
|
|
|
|
# The GNU General Public License, Version 3, June 2007 |
92
|
|
|
|
|
|
|
# |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=pod |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=for :stopwords Diab Jerius Smithsonian Astrophysical Observatory |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Data::Record::Serialize::Error - Error objects |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 VERSION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
version 1.05 |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 SYNOPSIS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use Data::Record::Serialize::Error -all; |
111
|
|
|
|
|
|
|
use Data::Record::Serialize::Error { errors => |
112
|
|
|
|
|
|
|
[ qw( param |
113
|
|
|
|
|
|
|
connect |
114
|
|
|
|
|
|
|
schema |
115
|
|
|
|
|
|
|
create |
116
|
|
|
|
|
|
|
insert |
117
|
|
|
|
|
|
|
)] }, -all; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 For the user of C<Data::Record::Serialize> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Most errors result in exception objects being thrown, typically in the |
124
|
|
|
|
|
|
|
C<Data::Record::Serialize::Error> hierarchy. The exception objects |
125
|
|
|
|
|
|
|
will stringify to an appropriate error message. Additional payload |
126
|
|
|
|
|
|
|
data may be returned as well (see the documentation for the individual |
127
|
|
|
|
|
|
|
modules which throw exceptions). The objects are derived from |
128
|
|
|
|
|
|
|
L<failures> and have the attributes documented in |
129
|
|
|
|
|
|
|
L<failures/Attributes>. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 For the developer |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This module organizes L<Data::Record::Serialize> errors based upon |
134
|
|
|
|
|
|
|
L<custom::failures>. It uses L<Exporter::Shiny>. The global option |
135
|
|
|
|
|
|
|
C<errors> may be used to construct a set of error classes. C<errors> |
136
|
|
|
|
|
|
|
is passed an array of error names; if they begin with C<::> they are |
137
|
|
|
|
|
|
|
relative to C<Data::Record::Serialize::Error>, otherwise they are |
138
|
|
|
|
|
|
|
relative to the C<Error> sub-hierarchy under the calling package. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
For example, |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
package Data::Record::Serialize::Bar; |
143
|
|
|
|
|
|
|
use Data::Record::Serialize::Error { errors => [ '::foo', 'foo' ] }; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
will construct error classes C<Data::Record::Serialize::Error::foo> |
146
|
|
|
|
|
|
|
and C<Data::Record::Serialize::Bar::Error::foo>; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 Error Class Names |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Names (passed either during module import or to the L</error> subroutine) |
151
|
|
|
|
|
|
|
are converted to fully qualified class names via the following: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
if a name begins with C<::> it is relative to C<Data::Record::Serialize::Error> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
otherwise it is relative to the C<Error> sub-hierarchy under the calling package. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=back |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
For example, in |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package Data::Record::Serialize::Bar; |
168
|
|
|
|
|
|
|
use Data::Record::Serialize::Error { errors => [ '::foo', 'foo' ] }; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
error( '::foo', @stuff ); |
171
|
|
|
|
|
|
|
error( 'foo', @stuff ); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
C<::foo> will be converted to C<Data::Record::Serialize::Error::foo> |
174
|
|
|
|
|
|
|
and C<foo> to C<Data::Record::Serialize::Bar::Error::foo>. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 OBJECT ATTRIBUTES |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 msg |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 payload |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 trace |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
See L<failures/Attributes>. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 SUBROUTINES |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 error |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
error( $error_class, @_ ); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Throw an error. C<$error_class> is converted to a fully qualified class |
193
|
|
|
|
|
|
|
name; see L</Error Class Names>. The remaining parameters are passed |
194
|
|
|
|
|
|
|
directly to the L<failures> throw method (see L<failures/Throwing |
195
|
|
|
|
|
|
|
failures>). |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 INTERNALS |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 SUPPORT |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 Bugs |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Please report any bugs or feature requests to bug-data-record-serialize@rt.cpan.org or through the web interface at: L<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Record-Serialize> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 Source |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Source is available at |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
https://gitlab.com/djerius/data-record-serialize |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
and may be cloned from |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
https://gitlab.com/djerius/data-record-serialize.git |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 SEE ALSO |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Please see those modules/websites for more information related to this module. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over 4 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L<Data::Record::Serialize|Data::Record::Serialize> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 AUTHOR |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Diab Jerius <djerius@cpan.org> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This software is Copyright (c) 2017 by Smithsonian Astrophysical Observatory. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This is free software, licensed under: |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |