line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::BIMI::Role::HasError; |
2
|
|
|
|
|
|
|
# ABSTRACT: Class to model an error |
3
|
|
|
|
|
|
|
our $VERSION = '3.20210512'; # VERSION |
4
|
29
|
|
|
29
|
|
22600
|
use 5.20.0; |
|
29
|
|
|
|
|
116
|
|
5
|
29
|
|
|
29
|
|
14559
|
use Moose::Role; |
|
29
|
|
|
|
|
149328
|
|
|
29
|
|
|
|
|
127
|
|
6
|
29
|
|
|
29
|
|
163320
|
use Mail::BIMI::Prelude; |
|
29
|
|
|
|
|
88
|
|
|
29
|
|
|
|
|
253
|
|
7
|
29
|
|
|
29
|
|
24792
|
use Mail::BIMI::Trait::Cacheable; |
|
29
|
|
|
|
|
97
|
|
|
29
|
|
|
|
|
1105
|
|
8
|
29
|
|
|
29
|
|
16041
|
use Mail::BIMI::Trait::CacheSerial; |
|
29
|
|
|
|
|
101
|
|
|
29
|
|
|
|
|
1062
|
|
9
|
29
|
|
|
29
|
|
15578
|
use Mail::BIMI::Error; |
|
29
|
|
|
|
|
109
|
|
|
29
|
|
|
|
|
1326
|
|
10
|
29
|
|
|
29
|
|
244
|
use Sub::Install; |
|
29
|
|
|
|
|
70
|
|
|
29
|
|
|
|
|
297
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has errors => ( is => 'rw', isa => 'ArrayRef', lazy => 1, default => sub{return []}, traits => ['Cacheable','CacheSerial'] ); |
13
|
|
|
|
|
|
|
has warnings => ( is => 'rw', isa => 'ArrayRef', lazy => 1, default => sub{return []}, traits => ['Cacheable'] ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
14
|
|
|
14
|
1
|
2562
|
sub serialize_errors($self) { |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
20
|
|
18
|
14
|
|
|
|
|
420
|
my @data = map {{ |
19
|
5
|
|
|
|
|
103
|
code => $_->code, |
20
|
|
|
|
|
|
|
detail => $_->detail, |
21
|
|
|
|
|
|
|
}} $self->errors->@*; |
22
|
14
|
|
|
|
|
70
|
return \@data; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
7
|
1
|
3503
|
sub deserialize_errors($self,$value) { |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
15
|
|
27
|
7
|
|
|
|
|
33
|
foreach my $error ($value->@*) { |
28
|
|
|
|
|
|
|
my $error_object = Mail::BIMI::Error->new( |
29
|
|
|
|
|
|
|
code => $error->{code}, |
30
|
2
|
100
|
|
|
|
16
|
( $error->{detail} ? ( detail => $error->{detail} ) : () ), |
31
|
|
|
|
|
|
|
); |
32
|
2
|
|
|
|
|
1220
|
$self->add_error_object($error_object); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
25
|
|
|
25
|
1
|
4402
|
sub add_error($self,$code,$detail=undef) { |
|
25
|
|
|
|
|
53
|
|
|
25
|
|
|
|
|
74
|
|
|
25
|
|
|
|
|
54
|
|
|
25
|
|
|
|
|
124
|
|
38
|
25
|
100
|
|
|
|
364
|
my $error = Mail::BIMI::Error->new( |
39
|
|
|
|
|
|
|
code=>$code, |
40
|
|
|
|
|
|
|
($detail?(detail=>$detail):()), |
41
|
|
|
|
|
|
|
); |
42
|
25
|
|
|
|
|
18725
|
$self->add_error_object($error); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
1
|
0
|
sub add_warning($self,$detail) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
47
|
0
|
|
|
|
|
0
|
push $self->warnings->@*, $detail; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
33
|
|
|
33
|
1
|
72
|
sub add_error_object($self,$error) { |
|
33
|
|
|
|
|
64
|
|
|
33
|
|
|
|
|
54
|
|
|
33
|
|
|
|
|
54
|
|
52
|
33
|
100
|
|
|
|
120
|
if ( ref $error eq 'ARRAY' ) { |
53
|
3
|
|
|
|
|
16
|
foreach my $suberror ( $error->@* ){ |
54
|
3
|
|
|
|
|
17
|
$self->add_error_object($suberror); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
30
|
100
|
|
|
|
822
|
$self->log_verbose(join(' : ', |
59
|
|
|
|
|
|
|
'Error', |
60
|
|
|
|
|
|
|
$error->code, |
61
|
|
|
|
|
|
|
$error->description, |
62
|
|
|
|
|
|
|
( $error->detail ? $error->detail : () ), |
63
|
|
|
|
|
|
|
)); |
64
|
30
|
|
|
|
|
831
|
push $self->errors->@*, $error; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
30
|
|
|
30
|
1
|
64
|
sub error_codes($self) { |
|
30
|
|
|
|
|
61
|
|
|
30
|
|
|
|
|
53
|
|
70
|
30
|
|
|
|
|
857
|
my @error_codes = map { $_->code } $self->errors->@*; |
|
20
|
|
|
|
|
474
|
|
71
|
30
|
|
|
|
|
337
|
return \@error_codes; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
22
|
|
|
22
|
1
|
45
|
sub filter_errors($self,$error) { |
|
22
|
|
|
|
|
43
|
|
|
22
|
|
|
|
|
40
|
|
|
22
|
|
|
|
|
39
|
|
76
|
22
|
|
|
|
|
587
|
return grep { $_->code eq $error } $self->errors->@*; |
|
22
|
|
|
|
|
557
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=pod |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=encoding UTF-8 |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Mail::BIMI::Role::HasError - Class to model an error |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 VERSION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
version 3.20210512 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Role for handling validation errors and warnings |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 METHODS |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 I<serialize_errors()> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Serialize the errors property for cache storage |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 I<deserialize_errors($value)> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
De-serialize the errors property for cache storage |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 I<add_error($code,$detail)> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Add an error with the given code and optional detail to the current operation. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 I<add_warning($detail)> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Add a warning which may be returned to a validator. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 I<add_error_object($error)> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Add an existing error object, or objects, to the current operation |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 I<error_codes> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Return an ArrayRef of current error codes |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 I<filter_errors($error)> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Return error(s) matching the given error code |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 REQUIRES |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Error|Mail::BIMI::Error> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Trait::CacheSerial|Mail::BIMI::Trait::CacheSerial> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * L<Mail::BIMI::Trait::Cacheable|Mail::BIMI::Trait::Cacheable> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * L<Moose::Role|Moose::Role> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * L<Sub::Install|Sub::Install> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Marc Bradshaw <marc@marcbradshaw.net> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Marc Bradshaw. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
156
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=cut |