diff --git a/src/core.c/Promise.pm6 b/src/core.c/Promise.pm6 index 778f33d4eb3..e56e53b2468 100644 --- a/src/core.c/Promise.pm6 +++ b/src/core.c/Promise.pm6 @@ -15,10 +15,10 @@ my class X::Promise::Vowed is Exception { has $.promise; method message() { "Access denied to keep/break this Promise; already vowed" } } -my class X::Promise::IllegalTransition is Exception { +my class X::Promise::Resolved is Exception { has $.promise; method message() { - "Illegal attempt to keep/break this Promise (status: $!promise.status())"; + "Cannot keep/break a Promise more than once (status: $!promise.status())"; } } my role X::Promise::Broken { @@ -102,7 +102,7 @@ my class Promise does Awaitable { method !keep(Mu \result --> Nil) { $!lock.protect({ - X::Promise::IllegalTransition.new(promise => self).throw + X::Promise::Resolved.new(promise => self).throw if $!status != Planned; $!result := result; @@ -134,7 +134,7 @@ my class Promise does Awaitable { method !break(\result --> Nil) { $!lock.protect({ - X::Promise::IllegalTransition.new(promise => self).throw + X::Promise::Resolved.new(promise => self).throw if $!status != Planned; $!result := nqp::istype(result, Exception)