SPF/Exception.pm

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