Subject: | [PATCH] silence an error in an eval |
Date: | Sun, 9 Jan 2011 11:48:58 +0000 |
To: | bug-Email-Valid [...] rt.cpan.org |
From: | Andrew Sayers <andrew [...] slando.com> |
We find it useful to trap all errors in our program, as errors within
'eval' blocks occasionally contain vital debugging clues.
Email::Valid sometimes throws an error inside an eval, confusing our
logs. Please consider the following patch, that would squash the
error:
$ diff -Naur /opt/slando/perl/lib/site_perl/5.12.2/Email/Valid.pm Valid.pm
--- /opt/slando/perl/lib/site_perl/5.12.2/Email/Valid.pm
2010-06-11 03:05:55.000000000 +0100
+++ Valid.pm 2011-01-09 11:23:13.000000000 +0000
@@ -311,7 +311,7 @@
local_rules )], \@_);
my $addr = $args{address} or return $self->details('rfc822');
- $addr = $addr->address if eval { $addr->isa('Mail::Address') };
+ $addr = $addr->address if eval { ref($addr) && $addr->isa('Mail::Address') };
$addr = $self->_fudge( $addr ) if $args{fudge};
$self->rfc822( -address => $addr ) or return undef;
Message body is not shown because sender requested not to inline it.