Merge pull request #93 from flimzy/fault-cleanup

Update fault()'s output to inidcate the possible meaninglessness of the error
This commit is contained in:
Matt Simerson 2014-09-11 10:05:14 -07:00
commit 78425a0897
3 changed files with 8 additions and 4 deletions

View File

@ -58,7 +58,9 @@ sub respond {
sub fault { sub fault {
my $self = shift; my $self = shift;
my ($msg) = shift || "program fault - command not performed"; my ($msg) = shift || "program fault - command not performed";
print STDERR "$0 [$$]: $msg ($!)\n"; print STDERR "$0 [$$]: $msg\n";
print STDERR $name, "[$$]: Last system error: $!"
." (Likely irelevant--debug the crashed plugin to ensure it handles \$! properly)";
$self->respond("Error - " . $msg); $self->respond("Error - " . $msg);
return $PROMPT; return $PROMPT;
} }

View File

@ -90,7 +90,9 @@ sub fault {
my $self = shift; my $self = shift;
my ($msg) = shift || "program fault - command not performed"; my ($msg) = shift || "program fault - command not performed";
my ($name) = split /\s+/, $0, 2; my ($name) = split /\s+/, $0, 2;
print STDERR $name, "[$$]: $msg ($!)\n"; print STDERR $name, "[$$]: $msg\n";
print STDERR $name, "[$$]: Last system error: $!"
." (Likely irelevant--debug the crashed plugin to ensure it handles \$! properly)";
return $self->respond(451, "Internal error - try again later - " . $msg); return $self->respond(451, "Internal error - try again later - " . $msg);
} }

View File

@ -10,14 +10,14 @@ ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
{ {
my $fault; my $fault;
stderr_like { $fault = $smtpd->fault } stderr_like { $fault = $smtpd->fault }
qr/program fault - command not performed \(/, qr/program fault - command not performed.*Last system error:/ms,
'fault outputs proper warning to STDOUT'; 'fault outputs proper warning to STDOUT';
is($fault->[0], 451, 'fault returns 451'); is($fault->[0], 451, 'fault returns 451');
}; };
{ {
my $fault; my $fault;
stderr_like { $fault = $smtpd->fault('test message') } stderr_like { $fault = $smtpd->fault('test message') }
qr/test message \(/, qr/test message.*Last system error/ms,
'fault outputs proper custom warning to STDOUT'; 'fault outputs proper custom warning to STDOUT';
is($fault->[1], 'Internal error - try again later - test message', is($fault->[1], 'Internal error - try again later - test message',
'returns the input message'); 'returns the input message');