The problem is that no exceptions in promise handlers are fatal, they occur
in the event loop. The only way the exception could be propagated is if the
call to ->wait checked for a failure and rethrew it as an exception
afterward (this is how ->get works in Future). Also note that $p is not the
last promise in the chain, that is returned by the ->catch call (so you
would normally chain ->wait after that). I'm not sure what the idiomatic
way is to accomplish this with promises.

-Dan

On Thu, Nov 16, 2017 at 2:23 AM, Rob Foehl <[email protected]> wrote:

> Just ran into this on 7.55:
>
> ╶➤ perl -MMojo::Promise -le 'my $p = Mojo::Promise->new; $p->reject("die,
> please"); $p->catch(sub { die "oops: $_[0]\n" }); $p->wait'
>
> Silence...  Change the die to a warn, and:
>
> ╶➤ perl -MMojo::Promise -le 'my $p = Mojo::Promise->new; $p->reject("die,
> please"); $p->catch(sub { warn "oops: $_[0]\n" }); $p->wait'
> oops: die, please
>
> The promise is correctly rejected (confirmed by poking at $p->{status}),
> but the exception disappears.  I'm guessing that wasn't the intent, but I'm
> not entirely sure after a brief glance at the implementation...
>
> -Rob
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to