Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix Exception.gist when there's no message.
If the VM-level exception was missing a message, then Exception.gist
would crash. Refactored a little to avoid a duplicate isconcrete check
to make the code little tidier.
  • Loading branch information
jnthn committed Jul 18, 2015
1 parent ca6cdb4 commit a9136d2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/Exception.pm
Expand Up @@ -16,17 +16,20 @@ my class Exception {
}

multi method gist(Exception:D:) {
my $str = nqp::isconcrete($!ex)
?? nqp::p6box_s(nqp::getmessage($!ex))
!! try self.?message;
$str //= "Internal error";

my $str;
if nqp::isconcrete($!ex) {
my str $message = nqp::getmessage($!ex);
$str = nqp::isnull_s($message)
?? "Died with {self.^name}"
!! nqp::p6box_s($message);
$str ~= "\n";
try $str ~= self.backtrace
|| Backtrace.new()
|| ' (no backtrace available)';
}
else {
$str = (try self.?message) // "Internal error";
}
$str;
}

Expand Down

0 comments on commit a9136d2

Please sign in to comment.