Skip to content
Permalink
Browse files

Make sure creating a Failure from a Failure object throws

Fixes R#2764, sortiz++ for the spot
  • Loading branch information...
lizmat committed Mar 15, 2019
1 parent 33e2d7f commit c9110654bd5e9dffc163627f13b896b25dff0679
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/core/Failure.pm6
@@ -14,20 +14,21 @@ my class Failure is Nil {
self
}

multi method new() {
multi method new(Failure:D:) { self!throw }
multi method new(Failure:U:) {
my $stash := CALLER::;
my $payload = $stash<$!>.DEFINITE ?? $stash<$!> !! "Failed";
nqp::create(self)!SET-SELF(
$payload ~~ Exception ?? $payload !! X::AdHoc.new(:$payload)
)
}
multi method new(Exception:D \exception) {
multi method new(Failure:U: Exception:D \exception) {
nqp::create(self)!SET-SELF(exception)
}
multi method new($payload) {
multi method new(Failure:U: $payload) {
nqp::create(self)!SET-SELF(X::AdHoc.new(:$payload))
}
multi method new(|cap (*@msg)) {
multi method new(Failure:U: |cap (*@msg)) {
nqp::create(self)!SET-SELF(X::AdHoc.from-slurpy(|cap))
}

0 comments on commit c911065

Please sign in to comment.
You can’t perform that action at this time.