Subject: | ->resolve should croak on non existant file |
Hi,
The current behaviour of ->resolve is not very helpful:
$ perl -MPath::Class -e 'dir("/foo")->resolve'
No such file or directory at
/home/danielt/perl5/perlbrew/perls/perl-5.14.0/lib/site_perl/5.14.0/Path/Class/Entity.pm
line 66.
The attached patch fixes that:
$ perl -Ilib -MPath::Class -e 'dir("/foo")->resolve'
No such file or directory at -e line 1
Cheers,
Danijel
Subject: | path-croak.diff |
Index: lib/Path/Class/Entity.pm
===================================================================
--- lib/Path/Class/Entity.pm (revision 236)
+++ lib/Path/Class/Entity.pm (working copy)
@@ -5,6 +5,7 @@
use File::Spec 0.87;
use File::stat ();
use Cwd;
+use Carp();
use overload
(
@@ -60,7 +61,7 @@
sub resolve {
my $self = shift;
- die $! unless -e $self; # No such file or directory
+ Carp::croak($!) unless -e $self; # No such file or directory
my $cleaned = $self->new( scalar Cwd::realpath($self->stringify) );
# realpath() always returns absolute path, kind of annoying