line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::ToPerl6::Exception::AggregateConfiguration; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
13
|
use 5.006001; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Carp qw{ confess }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
5
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
9
|
1
|
|
|
1
|
|
383
|
use Readonly; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
760
|
use Perl::ToPerl6::Utils qw{ :characters }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Exception::Class ( |
16
|
1
|
|
|
|
|
11
|
'Perl::ToPerl6::Exception::AggregateConfiguration' => { |
17
|
|
|
|
|
|
|
isa => 'Perl::ToPerl6::Exception', |
18
|
|
|
|
|
|
|
description => 'A collected set of configuration exceptions.', |
19
|
|
|
|
|
|
|
fields => [ qw{ exceptions } ], |
20
|
|
|
|
|
|
|
alias => 'throw_aggregate', |
21
|
|
|
|
|
|
|
}, |
22
|
1
|
|
|
1
|
|
730
|
); |
|
1
|
|
|
|
|
2
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw< throw_aggregate >; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new { |
31
|
128
|
|
|
128
|
1
|
17639
|
my ($class, %options) = @_; |
32
|
|
|
|
|
|
|
|
33
|
128
|
|
|
|
|
191
|
my $exceptions = $options{exceptions}; |
34
|
128
|
50
|
|
|
|
276
|
if (not $exceptions) { |
35
|
128
|
|
|
|
|
234
|
$options{exceptions} = []; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
128
|
|
|
|
|
467
|
return $class->SUPER::new(%options); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub add_exception { |
44
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $exception ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
push @{ $self->exceptions() }, $exception; |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub add_exceptions_from { |
54
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $aggregate ) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
push @{ $self->exceptions() }, @{ $aggregate->exceptions() }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub add_exception_or_rethrow { |
64
|
38
|
|
|
38
|
1
|
54
|
my ( $self, $eval_error ) = @_; |
65
|
|
|
|
|
|
|
|
66
|
38
|
50
|
|
|
|
118
|
return if not $eval_error; |
67
|
0
|
0
|
|
|
|
0
|
confess $eval_error if not ref $eval_error; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if ( $eval_error->isa('Perl::ToPerl6::Exception::Configuration') ) { |
|
|
0
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
$self->add_exception($eval_error); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
elsif ( |
73
|
|
|
|
|
|
|
$eval_error->isa('Perl::ToPerl6::Exception::AggregateConfiguration') |
74
|
|
|
|
|
|
|
) { |
75
|
0
|
|
|
|
|
0
|
$self->add_exceptions_from($eval_error); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
0
|
die $eval_error; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub has_exceptions { |
87
|
128
|
|
|
128
|
1
|
164
|
my ( $self ) = @_; |
88
|
|
|
|
|
|
|
|
89
|
128
|
50
|
|
|
|
131
|
return @{ $self->exceptions() } ? 1 : 0; |
|
128
|
|
|
|
|
2621
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_PREFIX => $EMPTY; |
95
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_SUFFIX => "\n"; |
96
|
|
|
|
|
|
|
Readonly::Scalar my $MESSAGE_SEPARATOR => $MESSAGE_SUFFIX . $MESSAGE_PREFIX; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub full_message { |
99
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $message = $MESSAGE_PREFIX; |
102
|
0
|
|
|
|
|
|
$message .= join $MESSAGE_SEPARATOR, @{ $self->exceptions() }; |
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$message .= $MESSAGE_SUFFIX; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $message; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=for stopwords |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Perl::ToPerl6::Exception::AggregateConfiguration - A collection of a set of problems found in the configuration and/or command-line options. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
A set of configuration settings can have multiple problems. This is |
125
|
|
|
|
|
|
|
an object for collecting all the problems found so that the user can |
126
|
|
|
|
|
|
|
see them in one run. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 INTERFACE SUPPORT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is considered to be a public class. Any changes to its interface |
132
|
|
|
|
|
|
|
will go through a deprecation cycle. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 METHODS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item C<add_exception( $exception )> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Accumulate the parameter with rest of the exceptions. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item C<add_exceptions_from( $aggregate )> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Accumulate the exceptions from another instance of this class. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item C<exceptions()> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns a reference to an array of the collected exceptions. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item C<add_exception_or_rethrow( $eval_error )> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
If the parameter is an instance of |
157
|
|
|
|
|
|
|
L<Perl::ToPerl6::Exception::Configuration|Perl::ToPerl6::Exception::Configuration> |
158
|
|
|
|
|
|
|
or |
159
|
|
|
|
|
|
|
L<Perl::ToPerl6::Exception::AggregateConfiguration|Perl::ToPerl6::Exception::AggregateConfiguration>, |
160
|
|
|
|
|
|
|
add it. Otherwise, C<die> with the parameter, if it is a reference, |
161
|
|
|
|
|
|
|
or C<confess> with it. If the parameter is false, simply returns. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item C<has_exceptions()> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Answer whether any configuration problems have been found. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item C<full_message()> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Concatenate the exception messages. See |
172
|
|
|
|
|
|
|
L<Exception::Class/"full_message">. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 AUTHOR |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Elliot Shank <perl@galumph.com> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head1 COPYRIGHT |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
Copyright (c) 2007-2011 Elliot Shank. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
187
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
188
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
############################################################################## |
193
|
|
|
|
|
|
|
# Local Variables: |
194
|
|
|
|
|
|
|
# mode: cperl |
195
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
196
|
|
|
|
|
|
|
# fill-column: 78 |
197
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
198
|
|
|
|
|
|
|
# c-indentation-style: bsd |
199
|
|
|
|
|
|
|
# End: |
200
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |