Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make "use lib" error more awesome
$ 6 'use lib'
===SORRY!=== Error while compiling -e
Must specify at least one repository.  Did you mean 'use lib "lib"' ?
  • Loading branch information
lizmat committed Mar 13, 2016
1 parent 24d42d1 commit a3422a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Perl6/World.nqp
Expand Up @@ -812,9 +812,14 @@ class Perl6::World is HLL::World {
elsif $*PKGDECL {
self.throw($/, 'X::Package::UseLib', :what($*PKGDECL) );
}
my $registry := self.find_symbol(['CompUnit', 'RepositoryRegistry']);
for $arglist -> $arg {
$registry.use-repository($registry.repository-for-spec($arg));
if nqp::islist($arglist) {
my $registry := self.find_symbol(['CompUnit', 'RepositoryRegistry']);
for $arglist -> $arg {
$registry.use-repository($registry.repository-for-spec($arg));
}
}
else {
self.throw($/, 'X::LibNone');
}
}
else {
Expand Down
3 changes: 3 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -1677,6 +1677,9 @@ my class X::Match::Bool is Exception {
method message() { "Cannot use Bool as Matcher with '" ~ $.type ~ "'. Did you mean to use \$_ inside a block?" }
}

my class X::LibNone does X::Comp {
method message { q/Must specify at least one repository. Did you mean 'use lib "lib"' ?/ }
}
my class X::Package::UseLib does X::Comp {
has $.what;
method message { "Cannot 'use lib' inside a $.what" }
Expand Down

0 comments on commit a3422a0

Please sign in to comment.