Permalink
Browse files

Remove cut & paste error messages

  • Loading branch information...
1 parent a2b8282 commit 3cc44d2bbb8cd1ded57f56d265946eaf4f43cc69 @petdance committed May 7, 2012
Showing with 10 additions and 3 deletions.
  1. +10 −3 Next.pm
View
13 Next.pm
@@ -222,7 +222,7 @@ BEGIN {
sub files {
- ($_[0] eq __PACKAGE__) && die 'File::Next::files must not be invoked as File::Next->files';
+ die _bad_invocation() if $_[0] eq __PACKAGE__;
my ($parms,@queue) = _setup( \%files_defaults, @_ );
my $filter = $parms->{file_filter};
@@ -250,7 +250,7 @@ sub files {
sub dirs {
- ($_[0] eq __PACKAGE__) && die 'File::Next::dirs must not be invoked as File::Next->dirs';
+ die _bad_invocation() if $_[0] eq __PACKAGE__;
my ($parms,@queue) = _setup( \%files_defaults, @_ );
@@ -269,7 +269,7 @@ sub dirs {
sub everything {
- ($_[0] eq __PACKAGE__) && die 'File::Next::everything must not be invoked as File::Next->everything';
+ die _bad_invocation() if $_[0] eq __PACKAGE__;
my ($parms,@queue) = _setup( \%files_defaults, @_ );
my $filter = $parms->{file_filter};
@@ -293,6 +293,13 @@ sub everything {
}; # iterator
}
+sub _bad_invocation {
+ my $good = (caller(1))[3];
+ my $bad = $good;
+ $bad =~ s/(.+)::/$1->/;
+ return "$good must not be invoked as $bad";
+}
+
sub sort_standard($$) { return $_[0]->[1] cmp $_[1]->[1] } ## no critic (ProhibitSubroutinePrototypes)
sub sort_reverse($$) { return $_[1]->[1] cmp $_[0]->[1] } ## no critic (ProhibitSubroutinePrototypes)

0 comments on commit 3cc44d2

Please sign in to comment.