Skip to content

Commit

Permalink
Inlcude file name after the SORRY line
Browse files Browse the repository at this point in the history
that way bulk messages (like for missing subroutines) get the file
name exactly once (not 0 times as before, and not repeated for every occurrence either)
  • Loading branch information
moritz committed Aug 5, 2013
1 parent 89216fa commit 156de3b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/Perl6/World.nqp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2384,6 +2384,7 @@ class Perl6::World is HLL::World {
%opts<panic> := @panic[0] if @panic; %opts<panic> := @panic[0] if @panic;
%opts<sorrows> := p6ize_recursive(@*SORROWS) if @*SORROWS; %opts<sorrows> := p6ize_recursive(@*SORROWS) if @*SORROWS;
%opts<worries> := p6ize_recursive(@*WORRIES) if @*WORRIES; %opts<worries> := p6ize_recursive(@*WORRIES) if @*WORRIES;
%opts<filename> := nqp::box_s(nqp::getlexdyn('$?FILES'), self.find_symbol(['Str']));
try { try {
my $group_type := self.find_symbol(['X', 'Comp', 'Group']); my $group_type := self.find_symbol(['X', 'Comp', 'Group']);
return $group_type.new(|%opts); return $group_type.new(|%opts);
Expand Down
93 changes: 47 additions & 46 deletions src/core/Exception.pm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -132,51 +132,6 @@ sub COMP_EXCEPTION(|) {
} }
} }


my class X::Comp::Group is Exception {
has $.panic;
has @.sorrows;
has @.worries;

method is-compile-time() { True }

method gist(::?CLASS:D:) {
my $r = "";
if $.panic || @.sorrows {
my $color = %*ENV<RAKUDO_ERROR_COLOR> // $*OS ne 'MSWin32';
my ($red, $clear) = $color ?? ("\e[31m", "\e[0m") !! ("", "");
$r ~= "$red==={$clear}SORRY!$red===$clear\n";
for @.sorrows {
$r ~= .gist(:!sorry, :!expect) ~ "\n";
}
if $.panic {
$r ~= $.panic.gist(:!sorry) ~ "\n";
}
}
if @.worries {
$r ~= $.panic || @.sorrows
?? "Other potential difficulties:\n"
!! "Potential difficulties:\n";
for @.worries {
$r ~= .gist(:!sorry, :!expect).indent(4) ~ "\n";
}
}
$r
}

method message() {
my @m;
for @.sorrows {
@m.push(.message);
}
if $.panic {
@m.push($.panic.message);
}
for @.worries {
@m.push(.message);
}
@m.join("\n")
}
}


do { do {
sub is_runtime($bt) { sub is_runtime($bt) {
Expand Down Expand Up @@ -428,7 +383,7 @@ my role X::Comp is Exception {
method sorry_heading() { method sorry_heading() {
my $color = %*ENV<RAKUDO_ERROR_COLOR> // $*OS ne 'MSWin32'; my $color = %*ENV<RAKUDO_ERROR_COLOR> // $*OS ne 'MSWin32';
my ($red, $clear) = $color ?? ("\e[31m", "\e[0m") !! ("", ""); my ($red, $clear) = $color ?? ("\e[31m", "\e[0m") !! ("", "");
"$red==={$clear}SORRY!$red===$clear\n" "$red==={$clear}SORRY!$red===$clear Error while compiling $.filename\n"
} }
method SET_FILE_LINE($file, $line) { method SET_FILE_LINE($file, $line) {
$!filename = $file; $!filename = $file;
Expand All @@ -437,6 +392,52 @@ my role X::Comp is Exception {
} }
} }


my class X::Comp::Group does X::Comp {
has $.panic;
has @.sorrows;
has @.worries;

method is-compile-time() { True }

multi method gist(::?CLASS:D:) {
my $r = "";
if $.panic || @.sorrows {
my $color = %*ENV<RAKUDO_ERROR_COLOR> // $*OS ne 'MSWin32';
my ($red, $clear) = $color ?? ("\e[31m", "\e[0m") !! ("", "");
$r ~= "$red==={$clear}SORRY!$red===$clear Error while compiling $.filename\n";
for @.sorrows {
$r ~= .gist(:!sorry, :!expect) ~ "\n";
}
if $.panic {
$r ~= $.panic.gist(:!sorry) ~ "\n";
}
}
if @.worries {
$r ~= $.panic || @.sorrows
?? "Other potential difficulties:\n"
!! "Potential difficulties:\n";
for @.worries {
$r ~= .gist(:!sorry, :!expect).indent(4) ~ "\n";
}
}
$r
}

method message() {
my @m;
for @.sorrows {
@m.push(.message);
}
if $.panic {
@m.push($.panic.message);
}
for @.worries {
@m.push(.message);
}
@m.join("\n")
}
}

# XXX a hack for getting line numbers from exceptions from the metamodel # XXX a hack for getting line numbers from exceptions from the metamodel
my class X::Comp::AdHoc is X::AdHoc does X::Comp { my class X::Comp::AdHoc is X::AdHoc does X::Comp {
method is-compile-time() { True } method is-compile-time() { True }
Expand Down

0 comments on commit 156de3b

Please sign in to comment.