Skip to content

Commit

Permalink
Fix a few CX creation cases and don't give a null to p6box_s
Browse files Browse the repository at this point in the history
  • Loading branch information
peschwa committed Jul 5, 2016
1 parent 4188109 commit 1fbb8b4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/Exception.pm
Expand Up @@ -236,6 +236,9 @@ my class CX::Succeed does X::Control {
my class CX::Proceed does X::Control {
method message() { "<proceed control exception>" }
}
my class CX::Return does X::Control {
method message() { "<return control exception>" }
}

sub EXCEPTION(|) {
my Mu $vm_ex := nqp::shift(nqp::p6argvmarray());
Expand All @@ -246,13 +249,13 @@ sub EXCEPTION(|) {
} else {
my int $type = nqp::getextype($vm_ex);
my $ex;
if $type == nqp::const::CONTROL_NEXT {
if $type +& nqp::const::CONTROL_NEXT {
$ex := CX::Next.new();
}
elsif $type == nqp::const::CONTROL_REDO {
elsif $type +& nqp::const::CONTROL_REDO {
$ex := CX::Redo.new();
}
elsif $type == nqp::const::CONTROL_LAST {
elsif $type +& nqp::const::CONTROL_LAST {
$ex := CX::Last.new();
}
elsif $type == nqp::const::CONTROL_TAKE {
Expand All @@ -269,6 +272,9 @@ sub EXCEPTION(|) {
elsif $type == nqp::const::CONTROL_PROCEED {
$ex := CX::Proceed.new();
}
elsif $type == nqp::const::CONTROL_RETURN {
$ex := CX::Return.new();
}
elsif !nqp::isnull_s(nqp::getmessage($vm_ex)) &&
nqp::p6box_s(nqp::getmessage($vm_ex)) ~~ /"Method '" (.*?) "' not found for invocant of class '" (.+)\'$/ {
$ex := X::Method::NotFound.new(
Expand All @@ -278,7 +284,7 @@ sub EXCEPTION(|) {
}
else {
$ex := nqp::create(X::AdHoc);
nqp::bindattr($ex, X::AdHoc, '$!payload', nqp::p6box_s(nqp::getmessage($vm_ex)));
nqp::bindattr($ex, X::AdHoc, '$!payload', nqp::p6box_s(nqp::getmessage($vm_ex) // 'unknown exception'));
}
nqp::bindattr($ex, Exception, '$!ex', $vm_ex);
$ex;
Expand Down

0 comments on commit 1fbb8b4

Please sign in to comment.