Subject: | Not able to detect or process errors (e.g. permission denied etc.) |
Date: | Thu, 20 Nov 2008 23:52:31 -0800 |
To: | bug-File-Find-Rule [...] rt.cpan.org |
From: | Erik Steffl <steffl [...] bigfoot.com> |
It seems there is no way to detect or process errors, e.g. if there is
permission problem the message is printed to stderr (or stdout, didn't
check) but there doesn't seem to be a way to detect this error in the
script. I have read the docs at cpan.org
http://search.cpan.org/~rclamp/File-Find-Rule-0.30/lib/File/Find/Rule.pm
and tried eval (in case it was dying).
Sample script fragment:
use File::Find::Rule;
...
warn "cyrusDirectoryToImap: working on cyrus directory
[$cyrusDirname]\n";
eval {
foreach my $filename (File::Find::Rule->file()->in($cyrusDirname)) {
warn "file [$filename]\n";
}
};
if($@) {
chomp($@);
die "cyrusDirectoryToImap: error [$@]\n";
}
Sample output:
cyrusDirectoryToImap: working on cyrus directory
[/data/jojdaRecovered/var/spool/cyrus/mail/e/user/erik]
Can't stat /data/jojdaRecovered/var/spool/cyrus/mail/e/user/erik:
Permission denied
at /usr/share/perl5/File/Find/Rule.pm line 598
i.e. error is printed but script has no idea error occured.
System:
ubuntu 8.10
libfile-find-rule-perl 0.30-3
perl 5.10.0 built for i486-linux-gnu-thread-multi
erik