Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the File-pushd CPAN distribution.

Report information
The Basics
Id: 30274
Status: resolved
Priority: 0/
Queue: File-pushd

People
Owner: dagolden [...] cpan.org
Requestors: krishnoid [...] wapacut.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 1.00
Fixed in: (no value)



Subject: Docs don't describe what happens on error
Does pushd() return undef (I'd prefer this) or throw an exception on error when trying to chdir to the new directory? Also, does it set $! on error?
From: krishnoid [...] wapacut.com
On Thu Oct 25 18:17:19 2007, krishnoid@wapacut.com wrote: Show quoted text
> Does pushd() return undef (I'd prefer this) or throw an exception on > error when trying to chdir to the new directory? Also, does it set
$! on Show quoted text
> error?
It looks like it croaks: sub pushd { ... croak "Can't locate directory $target_dir: $@" if $@; if ($dest ne $orig) { chdir $dest or croak "Can't chdir to $dest\: $!"; } } But it doesn't croak in DESTROY when it can't chdir back to the previous directory: sub DESTROY { ... my $orig = $self->{_original}; chdir $orig if $orig; # should always be so, but just in case... ... } In any case, it would be helpful to describe both of these behaviors in the docs and show an example using eval {} for error-handling.
It's documented as croaking. Croaking in DESTROY would serve no purpose as Perl throws away such errors. Like most modules, since nothing is said about $!, you can't make any assumptions about what it holds. (It's really not reliable except right after a system call anyway.)