SPF/Exception.pm

filter: Statementstmt 76.4% 52 / 68 Branchbran 16.6% 1 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 54.5% 6 / 11 Podpod 66.6% 2 / 3 totaltotal 65.5% 61 / 93 CC 5 SCAR 14.4
CC
5
Cov
69%
name
12.0
stringify
6.0
new
2.0
CRAP 4.2
« SPF/Mod/Exp.pm ↑ Summary SPF/Base.pm »
1 #
2 # Mail::SPF::Exception
3 # Mail::SPF exception classes.
4 #
5 # (C) 2006 Julian Mehnle <julian@mehnle.net>
6 # $Id: Exception.pm 36 2006-12-09 19:01:46Z Julian Mehnle $
7 #
8 ##############################################################################
9  
10 package Mail::SPF::Exception;
11  
12 =head1 NAME
13  
14 Mail::SPF::Exception - SPF exception class
15  
16 =head1 VERSION
17  
18 version 3.20250505
19  
20 =cut
21  
22 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 7 ▶use base 'Error', 'Mail::SPF::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 7 ▶use constant TRUE => (0 == 0);
Subroutine BEGIN: called CC=1 SCAR=0.0
28 7 ▶use constant FALSE => not TRUE;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 sub new {
31 13 ▶ my ($self, $text) = @_;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
32 13 local $Error::Depth = $Error::Depth + 1;
33 13 ▶ return $self->SUPER::new(
Branch: 1 branch
BranchTrueFalseTotal
defined $text ? : 13 0 13
34 defined($text) ? (-text => $text) : ()
35 );
36 }
37  
38 sub stringify {
39 0 ▶ my ($self) = @_;
Subroutine stringify: not called CC=2 SCAR=17.9
Pod documented
40 0 my $text = $self->SUPER::stringify;
41 0 ▶ $text .= sprintf(" (%s) at %s line %d.\n", $self->name, $self->file, $self->line)
Branch: 1 branch
BranchTrueFalseTotal
unless $text =~ /\n$/s 0 0 0
42 if $text !~ /\n$/s;
43 0 return $text;
44 }
45  
46 sub name {
47 0 ▶ my ($self) = @_;
Subroutine name: not called CC=3 SCAR=24.8
Pod undocumented
48 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
49 0 ▶ return $class =~ /^Mail::SPF::(\w+)$/ ? $1 : $class;
Branch: 1 branch
BranchTrueFalseTotal
$class =~ /^Mail::SPF::(\w+)$/ ? : 0 0 0
50 }
51  
52  
53 # Generic Exceptions
54 ##############################################################################
55  
56 # Tried to call a class method as an instance method:
57 package Mail::SPF::EClassMethod;
58 7 our @ISA = qw(Mail::SPF::Exception);
59  
60 sub new {
61 0 ▶ my ($self) = @_;
Subroutine new: not called CC=1 SCAR=6.9
62 0 local $Error::Depth = $Error::Depth + 2;
63 0 return $self->SUPER::new(
64 sprintf('Pure class method %s called as an instance method', (caller($Error::Depth - 1))[3])
65 );
66 }
67  
68 # Tried to call an instance method as a class method:
69 package Mail::SPF::EInstanceMethod;
70 7 our @ISA = qw(Mail::SPF::Exception);
71  
72 sub new {
73 0 ▶ my ($self) = @_;
Subroutine new: not called CC=1 SCAR=6.9
74 0 local $Error::Depth = $Error::Depth + 2;
75 0 return $self->SUPER::new(
76 sprintf('Pure instance method %s called as a class method', (caller($Error::Depth - 1))[3])
77 );
78 }
79  
80 # Abstract class cannot be instantiated:
81 package Mail::SPF::EAbstractClass;
82 7 our @ISA = qw(Mail::SPF::Exception);
83  
84 sub new {
85 0 ▶ my ($self) = @_;
Subroutine new: not called CC=1 SCAR=6.9
86 0 local $Error::Depth = $Error::Depth + 2;
87 0 return $self->SUPER::new('Abstract class cannot be instantiated');
88 }
89  
90 # Missing required method option:
91 package Mail::SPF::EOptionRequired;
92 7 our @ISA = qw(Mail::SPF::Exception);
93  
94 # Invalid value for method option:
95 package Mail::SPF::EInvalidOptionValue;
96 7 our @ISA = qw(Mail::SPF::Exception);
97  
98 # Read-only value:
99 package Mail::SPF::EReadOnlyValue;
100 7 our @ISA = qw(Mail::SPF::Exception);
101  
102  
103 # Miscellaneous Errors
104 ##############################################################################
105  
106 # DNS error:
107 package Mail::SPF::EDNSError;
108 7 our @ISA = qw(Mail::SPF::Exception);
109  
110 # DNS timeout:
111 package Mail::SPF::EDNSTimeout;
112 7 our @ISA = qw(Mail::SPF::EDNSError);
113  
114 # Record selection error:
115 package Mail::SPF::ERecordSelectionError;
116 7 our @ISA = qw(Mail::SPF::Exception);
117  
118 # No acceptable record found:
119 package Mail::SPF::ENoAcceptableRecord;
120 7 our @ISA = qw(Mail::SPF::ERecordSelectionError);
121  
122 # Redundant acceptable records found:
123 package Mail::SPF::ERedundantAcceptableRecords;
124 7 our @ISA = qw(Mail::SPF::ERecordSelectionError);
125  
126 # No unparsed text available:
127 package Mail::SPF::ENoUnparsedText;
128 7 our @ISA = qw(Mail::SPF::Exception);
129  
130 # Unexpected term object encountered:
131 package Mail::SPF::EUnexpectedTermObject;
132 7 our @ISA = qw(Mail::SPF::Exception);
133  
134 # Processing limit exceeded:
135 package Mail::SPF::EProcessingLimitExceeded;
136 7 our @ISA = qw(Mail::SPF::Exception);
137  
138 # Missing required context for macro expansion:
139 package Mail::SPF::EMacroExpansionCtxRequired;
140 7 our @ISA = qw(Mail::SPF::EOptionRequired);
141  
142  
143 # Parser Errors
144 ##############################################################################
145  
146 # Nothing to parse:
147 package Mail::SPF::ENothingToParse;
148 7 our @ISA = qw(Mail::SPF::Exception);
149  
150 # Generic syntax error:
151 package Mail::SPF::ESyntaxError;
152 7 our @ISA = qw(Mail::SPF::Exception);
153  
154 # Invalid record version:
155 package Mail::SPF::EInvalidRecordVersion;
156 7 our @ISA = qw(Mail::SPF::ESyntaxError);
157  
158 # Invalid scope:
159 package Mail::SPF::EInvalidScope;
160 7 our @ISA = qw(Mail::SPF::ESyntaxError);
161  
162 # Junk encountered in record:
163 package Mail::SPF::EJunkInRecord;
164 7 our @ISA = qw(Mail::SPF::ESyntaxError);
165  
166 # Invalid term:
167 package Mail::SPF::EInvalidTerm;
168 7 our @ISA = qw(Mail::SPF::ESyntaxError);
169  
170 # Junk encountered in term:
171 package Mail::SPF::EJunkInTerm;
172 7 our @ISA = qw(Mail::SPF::ESyntaxError);
173  
174 # Invalid modifier:
175 package Mail::SPF::EInvalidMod;
176 7 our @ISA = qw(Mail::SPF::EInvalidTerm);
177  
178 # Duplicate global modifier:
179 package Mail::SPF::EDuplicateGlobalMod;
180 7 our @ISA = qw(Mail::SPF::EInvalidMod);
181  
182 # Invalid mechanism:
183 package Mail::SPF::EInvalidMech;
184 7 our @ISA = qw(Mail::SPF::EInvalidTerm);
185  
186 # Invalid mechanism qualifier:
187 package Mail::SPF::EInvalidMechQualifier;
188 7 our @ISA = qw(Mail::SPF::EInvalidMech);
189  
190 # Missing required <domain-spec> in term:
191 package Mail::SPF::ETermDomainSpecExpected;
192 7 our @ISA = qw(Mail::SPF::ESyntaxError);
193  
194 # Missing required <ip4-network> in term:
195 package Mail::SPF::ETermIPv4AddressExpected;
196 7 our @ISA = qw(Mail::SPF::ESyntaxError);
197  
198 # Missing required <ip4-cidr-length> in term:
199 package Mail::SPF::ETermIPv4PrefixLengthExpected;
200 7 our @ISA = qw(Mail::SPF::ESyntaxError);
201  
202 # Missing required <ip6-network> in term:
203 package Mail::SPF::ETermIPv6AddressExpected;
204 7 our @ISA = qw(Mail::SPF::ESyntaxError);
205  
206 # Missing required <ip6-cidr-length> in term:
207 package Mail::SPF::ETermIPv6PrefixLengthExpected;
208 7 our @ISA = qw(Mail::SPF::ESyntaxError);
209  
210 # Invalid macro string:
211 package Mail::SPF::EInvalidMacroString;
212 7 our @ISA = qw(Mail::SPF::ESyntaxError);
213  
214 # Invalid macro:
215 package Mail::SPF::EInvalidMacro;
216 7 our @ISA = qw(Mail::SPF::EInvalidMacroString);
217  
218  
219 package Mail::SPF::Exception;
220  
221 7 TRUE;
« SPF/Mod/Exp.pm ↑ Summary SPF/Base.pm »