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