BIMI/Error.pm

filter: Statementstmt 100% 18 / 18 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 28 / 28 CC 2 SCAR 2.5
CC
2
Cov
100%
result
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« BIMI/Base.pm ↑ Summary BIMI/Role/Data.pm »
1 package Mail::BIMI::Error;
2 # ABSTRACT: Class to represent an error condition
3 30 our $VERSION = '3.20260302'; # VERSION
4 30 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 30 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 30 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 30 ▶use Mail::BIMI::Prelude;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 30 my %ERROR_MAP = (
10 BIMI_INVALID => { description => 'Invalid BIMI Record' },
11 BIMI_NOT_ENABLED => { description => 'Domain is not BIMI enabled' },
12 CODE_MISSING_AUTHORITY => { description => 'No authority specified', result => 'temperror' },
13 CODE_MISSING_LOCATION => { description => 'No location specified', result => 'temperror' },
14 CODE_NOTHING_TO_VALIDATE => { description => 'Nothing To Validate', result => 'temperror' },
15 CODE_NO_DATA => { description => 'No Data', result => 'temperror' },
16 DMARC_NOT_ENFORCING => { description => 'DMARC Policy is not at enforcement', result => 'skipped' },
17 DMARC_NOT_PASS => { description => 'DMARC did not pass', result => 'skipped' },
18 DNS_ERROR => { description => 'DNS query error', result => 'temperror' },
19 DUPLICATE_KEY => { description => 'Duplicate key in record' },
20 EMPTY_L_TAG => { description => 'Domain declined to participate', result => 'declined' },
21 EMPTY_V_TAG => { description => 'Empty v tag' },
22 INVALID_TRANSPORT_A => { description => 'Invalid transport in authority' },
23 INVALID_TRANSPORT_L => { description => 'Invalid transport in location' },
24 INVALID_V_TAG => { description => 'Invalid v tag' },
25 MISSING_L_TAG => { description => 'Missing l tag' },
26 MISSING_V_TAG => { description => 'Missing v tag' },
27 MULTIPLE_AUTHORITIES => { description => 'Multiple entries for a found' },
28 MULTIPLE_LOCATIONS => { description => 'Multiple entries for l found' },
29 MULTI_BIMI_RECORD => { description => 'Multiple BIMI records found' },
30 NO_BIMI_RECORD => { description => 'No BIMI records found', result => 'none' },
31 NO_DKIM => { description => 'Insufficient authentication, DKIM required', result => 'skipped' },
32 NO_DMARC => { description => 'No DMARC', result => 'skipped' },
33 SPF_PLUS_ALL => { description => 'SPF +all detected', result => 'skipped' },
34 SVG_FETCH_ERROR => { description => 'Could not fetch SVG', result => 'temperror' },
35 SVG_GET_ERROR => { description => 'Could not fetch SVG', result => 'temperror' },
36 SVG_INVALID_XML => { description => 'Invalid XML in SVG' },
37 SVG_MISMATCH => { description => 'SVG in bimi-location did not match SVG in VMC' },
38 SVG_SIZE => { description => 'SVG Document exceeds maximum size' },
39 SVG_UNZIP_ERROR => { description => 'Error unzipping SVG' },
40 SVG_VALIDATION_ERROR => { description => 'SVG did not validate' },
41 VMC_EXPIRED => { description => 'VMC has expired' },
42 VMC_FETCH_ERROR => { description => 'Could not fetch VMC', result => 'temperror' },
43 VMC_PARSE_ERROR => { description => 'Could not parse VMC' },
44 VMC_REQUIRED => { description => 'VMC is required' },
45 VMC_VALIDATION_ERROR => { description => 'VMC did not validate' },
46 VMC_NO_EXPERIMENTAL => { description => 'Experimental VMC not accepted here' },
47 VMC_DISALLOWED_TYPE => { description => 'VMC Mark Type not supported here' },
48 );
49  
50 30 has code => ( is => 'ro', isa => enum([sort keys %ERROR_MAP]), required => 1,
51 documentation => 'inputs: Error code', );
52 30 has detail => ( is => 'ro', isa => 'Str', required => 0,
53 documentation => 'inputs: Human readable details', );
54  
55  
56 ▶sub description($self) {
Subroutine description: called CC=1 SCAR=0.0
Pod documented
57 40 return $ERROR_MAP{$self->code}->{description};
58 }
59  
60  
61 ▶sub result($self) {
Subroutine result: called CC=2 SCAR=6.9
Pod documented
62 10 ▶ return exists $ERROR_MAP{$self->code}->{result} ? $ERROR_MAP{$self->code}->{result} : 'fail';
Branch: 1 branch
BranchTrueFalseTotal
exists $ERROR_MAP{$self->code}{'result'} ? : 7 3 10
63 }
64  
65  
66 30 1;
67  
68 __END__
69  
70 =pod
71  
72 =encoding UTF-8
73  
74 =head1 NAME
75  
76 Mail::BIMI::Error - Class to represent an error condition
77  
78 =head1 VERSION
79  
80 version 3.20260302
81  
82 =head1 DESCRIPTION
83  
84 Class for representing an error condition
85  
86 =head1 INPUTS
87  
88 These values are used as inputs for lookups and verifications, they are typically set by the caller based on values found in the message being processed
89  
90 =head2 code
91  
92 is=ro required
93  
94 Error code
95  
96 =head2 detail
97  
98 is=ro
99  
100 Human readable details
101  
102 =head1 EXTENDS
103  
104 =over 4
105  
106 =item * L<Moose::Object>
107  
108 =back
109  
110 =head1 METHODS
111  
112 =head2 I<description()>
113  
114 Return the human readable description for this class of error
115  
116 =head2 I<result()>
117  
118 Return the Authentication-Results bimi= result for this class of error
119  
120 =head1 REQUIRES
121  
122 =over 4
123  
124 =item * L<Mail::BIMI::Prelude|Mail::BIMI::Prelude>
125  
126 =item * L<Moose|Moose>
127  
128 =item * L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints>
129  
130 =back
131  
132 =head1 AUTHOR
133  
134 Marc Bradshaw <marc@marcbradshaw.net>
135  
136 =head1 COPYRIGHT AND LICENSE
137  
138 This software is copyright (c) 2020 by Marc Bradshaw.
139  
140 This is free software; you can redistribute it and/or modify it under
141 the same terms as the Perl 5 programming language system itself.
142  
143 =cut
« BIMI/Base.pm ↑ Summary BIMI/Role/Data.pm »