Subject: | Better error diagnostics on failed connects |
Many thanks for this clever module.
I found only a problem if the connection to a pop3s server fails. In
these cases, the error message reads like this:
Can't call method "blocking" on an undefined value at
/usr/share/perl5/Net/POP3/SSLWrapper.pm line 26.
Which is quite confusing. Attached is a patch to change this into the
standard Net::POP3 behavior, which is just to return undef in case of
connection problems. In the patch is also a test case for the "can't
connect" case.
Regards,
Slaven
Subject: | 0001-better-error-handling-in-case-of-failed-connects-wit.patch |
From 59f7b08c445f5d00fb7517ff57ddc761bf58ad47 Mon Sep 17 00:00:00 2001
From: Slaven Rezic <srezic@iconmobile.com>
Date: Tue, 15 Jun 2010 15:48:41 +0200
Subject: [PATCH] better error handling in case of failed connects (with new test)
---
lib/Net/POP3/SSLWrapper.pm | 1 +
t/10_noconn.t | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
create mode 100755 t/10_noconn.t
diff --git a/lib/Net/POP3/SSLWrapper.pm b/lib/Net/POP3/SSLWrapper.pm
index 1917247..db9e8dd 100644
--- a/lib/Net/POP3/SSLWrapper.pm
+++ b/lib/Net/POP3/SSLWrapper.pm
@@ -19,6 +19,7 @@ sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
+ return if !$self;
$self->blocking(0); # XXX why need this?
return $self;
}
diff --git a/t/10_noconn.t b/t/10_noconn.t
new file mode 100755
index 0000000..3f96099
--- /dev/null
+++ b/t/10_noconn.t
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+use Net::POP3;
+use Net::POP3::SSLWrapper;
+
+pop3s {
+ ok(!Net::POP3->new('pop3.example.com'), 'Expected connection failure');
+};
--
1.7.0.3