From 8b1ff67604bbfcb723f16d4e6df9902c3f90784d Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Thu, 11 Sep 2014 11:58:31 -0500 Subject: [PATCH] Update fault()'s output to inidcate the possibly meaninglessness of the reported system error. --- lib/Qpsmtpd/ConfigServer.pm | 4 +++- lib/Qpsmtpd/SMTP.pm | 4 +++- t/misc.t | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Qpsmtpd/ConfigServer.pm b/lib/Qpsmtpd/ConfigServer.pm index 16d2d12..f2127fe 100644 --- a/lib/Qpsmtpd/ConfigServer.pm +++ b/lib/Qpsmtpd/ConfigServer.pm @@ -58,7 +58,9 @@ sub respond { sub fault { my $self = shift; 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); return $PROMPT; } diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index ba8885a..2ce95c2 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -90,7 +90,9 @@ sub fault { my $self = shift; my ($msg) = shift || "program fault - command not performed"; 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); } diff --git a/t/misc.t b/t/misc.t index cae183e..d538ca1 100644 --- a/t/misc.t +++ b/t/misc.t @@ -10,14 +10,14 @@ ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection"); { my $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'; is($fault->[0], 451, 'fault returns 451'); }; { my $fault; stderr_like { $fault = $smtpd->fault('test message') } - qr/test message \(/, + qr/test message.*Last system error/ms, 'fault outputs proper custom warning to STDOUT'; is($fault->[1], 'Internal error - try again later - test message', 'returns the input message');