[perl #132835] "An operation first awaited" error needs to be clearer
[email protected] (David E .)
| Newsgroups | perl.perl6.compiler |
|---|---|
| Message-ID | <[email protected]> |
# New Ticket Created by David E.
# Please include the string: [perl #132835]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=132835 >
I've wasted more time than I should've the past few days trying to
understand what this message means. At a minimum the documentation should
be updated, but preferably the error message itself should be clarified.
The example on https://docs.perl6.org/language/traps is not entirely clear,
and did not at all match the scenario I was hitting. The provided stack
trace also fails to point to the source of the issue.
A trivialized example:
say "Test await after fulfillment";
my $p = Promise.new();
my $vow = $p.vow;
$vow.break(1);
await $p;
Results in:
An operation first awaited:
in block <unit> at ../test.pl6 line 5
Died with the exception:
1
in block <unit> at ../test.pl6 line 5
This haiku-like message simply means that the Promise/Vow has been broken.
Farther, the exception points to the "await $p" line, when it's really the
"$vow.break" line that's responsible for the trouble.
I'd suggest a better error message in this case (if possible) would be
something like:
*A Promise was broken by ../test.pl6 line 4 awaited upon*
in block <unit> at ../test.pl6 line 5
Died with the exception:
1
in block <unit> at ../test.pl6 line 5
Just trying to do my part to make Perl6 better ;-)
- David