Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document exploding sunk Proc trap
There were a few RTs involving.
  • Loading branch information
zoffixznet committed Jul 22, 2016
1 parent 9302e6f commit 81f35fd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/Language/traps.pod6
Expand Up @@ -404,6 +404,25 @@ The nice thing about the distinction here is that it gives the developer the
option of passing pairs as either named or positional arguments, which can be
handy in various instances.
=head1 Exception Handling
=head2 Sunk C<Proc>
Some methods return a L<Proc> object. If it represents a failed process, C<Proc> itself
won't be exception-like, but B<sinking it> will cause an L<X::Proc::Unsuccessful>
exception to be thrown. That means this construct will throw, despite the C<try> in place:
try run("perl6", "-e", "exit 42");
say "still alive";
# OUTPUT: The spawned process exited unsuccessfully (exit code: 42)
This is because C<try> receives a C<Proc> and returns it, at which point it sinks and
throws. Explicitly sinking it inside the C<try> avoids the issue:
try sink run("perl6", "-e", "exit 42");
say "still alive";
# OUTPUT: still alive
=end pod

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 81f35fd

Please sign in to comment.