Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve failure to run script errors.
Add a special case (and clear message) for directory, avoid spewing a
pointless backtrace, and always report on stderr.
  • Loading branch information
jnthn committed Jul 15, 2015
1 parent 65d85a3 commit 35f6d68
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/HLL/Compiler.nqp
Expand Up @@ -341,11 +341,15 @@ class HLL::Compiler does HLL::Backend::Default {
if $filename eq '-' {
$in-handle := nqp::getstdin();
}
elsif nqp::stat($filename, nqp::const::STAT_ISDIR) {
nqp::sayfh(nqp::getstderr(), "Can not run directory $filename.");
$err := 1;
}
else {
$in-handle := nqp::open($filename, 'r');
}
CATCH {
nqp::say("Could not open $filename. $_");
nqp::sayfh(nqp::getstderr(), "Could not open $filename. $_");
$err := 1;
}
}
Expand All @@ -355,10 +359,11 @@ class HLL::Compiler does HLL::Backend::Default {
nqp::push(@codes, nqp::readallfh($in-handle));
nqp::closefh($in-handle);
CATCH {
$err := "Error while reading from file: $_";
nqp::sayfh(nqp::getstderr(), "Error while reading from file: $_");
$err := 1;
}
}
nqp::die($err) if $err;
nqp::exit(1) if $err;
}
my $code := join('', @codes);
my $?FILES := join(' ', @files);
Expand Down

0 comments on commit 35f6d68

Please sign in to comment.