| Mail-Qmail-Queue documentation | Contained in the Mail-Qmail-Queue distribution. |
Mail::Qmail::Queue::Error - Error handling for programs which emulate or use qmail-queue.
use Mail::Qmail::Queue::Error qw(:errcodes :fail);
print "blah\n"
or tempfail QQ_EXIT_WRITEERR,"Write error: $!\n";
if (has_virus($body)) {
permfail QQ_EXIT_REFUSED,"Message refused: it has a virus!!\n";
}
qfail $exit_status,"qmail-queue exited $exit_status\n";
Mail::Qmail::Queue::Error is designed to simplify error handling
for a program which emulates or uses a program implementing the
qmail-queue(8) (qmail-queue(8)) interface. It declares constants for
a variety of permanent and temporary error codes, and provides
shorthand methods similar to die that return an appropriate error
code. It also provides some methods to look at an error code returned
by qmail-queue and determine whether it is temporary or permanent.
These constants are defined in qmail-queue(8). They are mostly self-explanatory.
Exit with a temporary failure code, or die if in an eval. If
the first argument is numeric, or if the message starts with a number,
that will be used as the exit code. Otherwise, the temporary failure
code QQ_EXIT_BUG will be used.
Note that no checking of the failure code is done; if you pass a code that does not indicate temporary failure, it will be used as is.
Exit with a permanent failure code, or die if in an eval. If
the first argument is numeric, that will be used as the exit code.
Otherwise, the permanent failure code QQ_EXIT_REFUSED will be used.
Note that no checking of the failure code is done; if you pass a code that does not indicate permanent failure, it will be used as is.
Exit with a failure code, or die if in an eval. If the first
argument is numeric, that will be used as the exit code. Otherwise,
the temporary failure code QQ_EXIT_BUG will be used.
Test if the provided value is a temporary exit status.
Test if the provided value is a permanent exit status.
qmail-queue(8), Mail::Qmail::Queue::Message, Mail::Qmail::Queue::Receive::Body, Mail::Qmail::Queue::Receive::Envelope, Mail::Qmail::Queue::Send.
Copyright 2006 Scott Gifford.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Mail-Qmail-Queue documentation | Contained in the Mail-Qmail-Queue distribution. |
package Mail::Qmail::Queue::Error; our $VERSION = 0.02; # # Copyright 2006 Scott Gifford # # This library is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. use warnings; use strict; use base 'Exporter'; our %EXPORT_TAGS = ( errcodes => [qw( QQ_EXIT_ADDR_TOO_LONG QQ_EXIT_REFUSED QQ_EXIT_NOMEM QQ_EXIT_TIMEOUT QQ_EXIT_WRITEERR QQ_EXIT_READERR QQ_EXIT_BADCONF QQ_EXIT_NETERR QQ_EXIT_BADQHOME QQ_EXIT_BADQUEUEDIR QQ_EXIT_BADQUEUEPID QQ_EXIT_BADQUEUEMESS QQ_EXIT_BADQUEUEINTD QQ_EXIT_BADQUEUETODO QQ_EXIT_TEMPREFUSE QQ_EXIT_CONNTIMEOUT QQ_EXIT_NETREJECT QQ_EXIT_NETFAIL QQ_EXIT_BUG QQ_EXIT_BADENVELOPE )], fail => [qw(tempfail permfail qfail)], test => [qw(is_tempfail is_permfail)], ); our @EXPORT_OK = (map { @$_} values %EXPORT_TAGS); use Carp;
use constant QQ_EXIT_ADDR_TOO_LONG => 11;
use constant QQ_EXIT_REFUSED => 31;
use constant QQ_EXIT_NOMEM => 51;
use constant QQ_EXIT_TIMEOUT => 52;
use constant QQ_EXIT_WRITEERR => 53;
use constant QQ_EXIT_READERR => 54;
use constant QQ_EXIT_BADCONF => 55;
use constant QQ_EXIT_NETERR => 56;
use constant QQ_EXIT_BADQHOME => 61;
use constant QQ_EXIT_BADQUEUEDIR => 62;
use constant QQ_EXIT_BADQUEUEPID => 63;
use constant QQ_EXIT_BADQUEUEMESS => 64;
use constant QQ_EXIT_BADQUEUEINTD => 65;
use constant QQ_EXIT_BADQUEUETODO => 66;
use constant QQ_EXIT_TEMPREFUSE => 71;
use constant QQ_EXIT_CONNTIMEOUT => 72;
use constant QQ_EXIT_NETREJECT => 73;
use constant QQ_EXIT_NETFAIL => 74;
use constant QQ_EXIT_BUG => 81;
use constant QQ_EXIT_BADENVELOPE => 91;
sub tempfail(@) { unshift(@_,QQ_EXIT_BUG); goto &_fail; }
sub permfail(@) { unshift(@_,QQ_EXIT_REFUSED); goto &_fail; }
sub qfail(@) { goto &tempfail; }
sub is_tempfail { return !is_permfail(@_); }
sub is_permfail { return ($_[0] >= 11 and $_[0] <= 40); } sub _fail(@) { my $default_ec = shift; if ($^S) { # Eval die @_; } my $ec = ($_[0] =~ /^\d+$/) ? shift : $default_ec; carp @_; exit($ec); }
1;