Skip to content

Commit

Permalink
Not finding a module throws an exception again.
Browse files Browse the repository at this point in the history
The intention of not having an unnecessary stack trace was noble, but it made
it very hard (if not impossible) to catch the error with a try { } block, or
form within an eval.

Also awesomeified the error message to include report contents of @*INC.
  • Loading branch information
moritz committed May 21, 2010
1 parent f9c987e commit 6a7ded6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Perl6/Module/Loader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ method need($name, %name_adverbs?) {
Perl6::Module::Locator.find_module($name, @inc, %name_adverbs<ver>, %name_adverbs<auth>) !!
Perl6::Module::Locator.find_module_no_conditions($name, @inc);
if $pm_file eq '' {
pir::say("Unable to find module '$name'" ~
pir::die("Unable to find module '$name'" ~
(%name_adverbs<ver> ?? " with version '" ~ %name_adverbs<ver> ~ "'" !! "") ~
(%name_adverbs<ver> && %name_adverbs<auth> ?? ' and' !! '') ~
(%name_adverbs<auth> ?? " with authority '" ~ %name_adverbs<auth> ~ "'" !! "") ~
" in the @*INC directories.");
pir::exit__vI( 1 ); # or another more meaningful nonzero status
" in the @*INC directories.\n"
~ "(@*INC contains:\n "
~ pir::join("\n ", @*INC)
~ ")."
);
}

# Need not load file if we already did so.
Expand Down

0 comments on commit 6a7ded6

Please sign in to comment.