The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#
# Mail::SPF::Exception
# Mail::SPF exception classes.
#
# (C) 2006 Julian Mehnle <julian@mehnle.net>
# $Id: Exception.pm 22 2006-11-15 03:31:28Z Julian Mehnle $
#
##############################################################################
use strict;
use base 'Error', 'Mail::SPF::Base';
use constant TRUE => (0 == 0);
use constant FALSE => not TRUE;
sub new {
my ($self, $text) = @_;
local $Error::Depth = $Error::Depth + 1;
return $self->SUPER::new(
defined($text) ? (-text => $text) : ()
);
}
sub stringify {
my ($self) = @_;
my $text = $self->SUPER::stringify;
$text .= sprintf(" (%s) at %s line %d.\n", $self->name, $self->file, $self->line)
if $text !~ /\n$/s;
return $text;
}
sub name {
my ($self) = @_;
my $class = ref($self) || $self;
return $class =~ /^Mail::SPF::(\w+)$/ ? $1 : $class;
}
# Generic Exceptions
##############################################################################
# Tried to call a class method as an instance method:
our @ISA = qw(Mail::SPF::Exception);
sub new {
my ($self) = @_;
local $Error::Depth = $Error::Depth + 2;
return $self->SUPER::new(
sprintf('Pure class method %s called as an instance method', (caller($Error::Depth - 1))[3])
);
}
# Tried to call an instance method as a class method:
our @ISA = qw(Mail::SPF::Exception);
sub new {
my ($self) = @_;
local $Error::Depth = $Error::Depth + 2;
return $self->SUPER::new(
sprintf('Pure instance method %s called as a class method', (caller($Error::Depth - 1))[3])
);
}
# Abstract class cannot be instantiated:
our @ISA = qw(Mail::SPF::Exception);
sub new {
my ($self) = @_;
local $Error::Depth = $Error::Depth + 2;
return $self->SUPER::new('Abstract class cannot be instantiated');
}
# Missing required method option:
our @ISA = qw(Mail::SPF::Exception);
# Invalid value for method option:
our @ISA = qw(Mail::SPF::Exception);
# Read-only value:
our @ISA = qw(Mail::SPF::Exception);
# Miscellaneous Errors
##############################################################################
# DNS error:
our @ISA = qw(Mail::SPF::Exception);
# DNS timeout:
our @ISA = qw(Mail::SPF::EDNSError);
# No suitable record found:
our @ISA = qw(Mail::SPF::Exception);
# No unparsed text available:
our @ISA = qw(Mail::SPF::Exception);
# Unexpected term object encountered:
our @ISA = qw(Mail::SPF::Exception);
# Processing limit exceeded:
our @ISA = qw(Mail::SPF::Exception);
# Missing required context for macro expansion:
our @ISA = qw(Mail::SPF::EOptionRequired);
# Parser Errors
##############################################################################
# Nothing to parse:
our @ISA = qw(Mail::SPF::Exception);
# Generic syntax error:
our @ISA = qw(Mail::SPF::Exception);
# Invalid record version:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Invalid scope:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Junk encountered in record:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Invalid term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Junk encountered in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Invalid modifier:
our @ISA = qw(Mail::SPF::EInvalidTerm);
# Duplicate global modifier:
our @ISA = qw(Mail::SPF::EInvalidMod);
# Invalid mechanism:
our @ISA = qw(Mail::SPF::EInvalidTerm);
# Invalid mechanism qualifier:
our @ISA = qw(Mail::SPF::EInvalidMech);
# Missing required <domain-spec> in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Missing required <ip4-network> in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Missing required <ip4-cidr-length> in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Missing required <ip6-network> in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Missing required <ip6-cidr-length> in term:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Invalid macro string:
our @ISA = qw(Mail::SPF::ESyntaxError);
# Invalid macro:
our @ISA = qw(Mail::SPF::EInvalidMacroString);
TRUE;