Skip to content

Commit

Permalink
Make backtrace printing more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Apr 21, 2012
1 parent 0d3220f commit 06d40a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/Backtrace.pm
Expand Up @@ -80,13 +80,13 @@ my class Backtrace is List {
return $startidx.list unless $start;
my $current = $start.outer;
my %outers;
while $current {
while $current.defined {
%outers{$current.static_id} = $start;
$current = $current.outer;
}
my @outers;
loop (my Int $i = $startidx; $i < $.end; ++$i) {
if self.at_pos($i).code && %outers{self.at_pos($i).code.static_id} {
if self.at_pos($i).code && %outers{self.at_pos($i).code.static_id}.defined {
@outers.push: $i;
return @outers if self.at_pos($i).is-routine;
}
Expand Down
9 changes: 6 additions & 3 deletions src/core/Exception.pm
Expand Up @@ -10,9 +10,12 @@ my class Exception {
}

multi method gist(Exception:D:) {
my $str = try self.?message ~ "\n" ~ $.backtrace;
$! ?? "Error while creating error string: $!"
!! $str;
my $str = try self.?message;
return "Error while creating error string: $!" if $!;
$str ~= "\n";
try $str ~= self.backtrace;
return "$str\nError while creating backtrace: $!.message()\n$!.backtrace.full();" if $!;
return $str;
}

method throw() is hidden_from_backtrace {
Expand Down

0 comments on commit 06d40a0

Please sign in to comment.