Permalink
Browse files

better message for nonexistent files on the commandline.

  • Loading branch information...
1 parent 7399985 commit 6b97517ab5f34eb64f682c5639abf8a3132ab220 @timo timo committed Mar 12, 2013
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/HLL/Compiler.pm
View
@@ -445,10 +445,22 @@ class HLL::Compiler does HLL::Backend::Default {
my @files := nqp::islist($files) ?? $files !! [$files];
$!user_progname := nqp::join(',', @files);
my @codes;
- for @files {
+ for @files -> $filename {
+ if !nqp::stat($filename, 0) {
+ nqp::say("Could not stat $filename: No such file or directory.");
+ nqp::exit(1);
+ }
my $err := 0;
+ my $in-handle;
+ try {
+ $in-handle := nqp::open($filename, 'r');
+ CATCH {
+ nqp::say("Could not open $filename. $_");
+ $err := 1;
+ }
+ }
+ nqp::exit(1) if $err;
try {
- my $in-handle := nqp::open($_, 'r');
nqp::setencoding($in-handle, $encoding);
nqp::push_s(@codes, nqp::readallfh($in-handle));
nqp::closefh($in-handle);

0 comments on commit 6b97517

Please sign in to comment.