Subject: | Untrapped errors (addFile) |
Date: | Sat, 20 Mar 2010 14:47:21 -0700 (PDT) |
To: | Bug-Archive-Zip [...] rt.cpan.org |
From: | Sean Miller <fastbean_au [...] yahoo.com.au> |
Archive::Zip v 1.30
This is probably a normal severity bug.
When calling addFile with a file that does not exist instead of returning an error code indicating that the call was not successful an untrapped error is given. This can be worked around by wrapping the call in an eval, but given the existence of the error handler this should not be required.
perl example.pl
Can't call method "desiredCompressionLevel" on an undefined value at C:/Perl/sit
e/lib/Archive/Zip/Archive.pm line 249.
Contents of example.pl:
use strict;
use warnings;
use File::Temp;
use Archive::Zip;
sub handler { print "Trapped: @_\n" }
Archive::Zip::setErrorHandler( \&handler );
# Setup a temp filename and ensure that it does not exist
my $nonexistent = mktemp('XXXXXXXX');
die if -e $nonexistent;
my $zip = Archive::Zip->new();
# We have an error handler, and we test the return result.
$zip->addFile($nonexistent)
and die "There was a problem!";