File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -404,6 +404,25 @@ The nice thing about the distinction here is that it gives the developer the
404
404
option of passing pairs as either named or positional arguments, which can be
405
405
handy in various instances.
406
406
407
+ = head1 Exception Handling
408
+
409
+ = head2 Sunk C < Proc >
410
+
411
+ Some methods return a L < Proc > object. If it represents a failed process, C < Proc > itself
412
+ won't be exception-like, but B < sinking it > will cause an L < X::Proc::Unsuccessful >
413
+ exception to be thrown. That means this construct will throw, despite the C < try > in place:
414
+
415
+ try run("perl6", "-e", "exit 42");
416
+ say "still alive";
417
+ # OUTPUT: The spawned process exited unsuccessfully (exit code: 42)
418
+
419
+ This is because C < try > receives a C < Proc > and returns it, at which point it sinks and
420
+ throws. Explicitly sinking it inside the C < try > avoids the issue:
421
+
422
+ try sink run("perl6", "-e", "exit 42");
423
+ say "still alive";
424
+ # OUTPUT: still alive
425
+
407
426
= end pod
408
427
409
428
# vim: expandtab shiftwidth=4 ft=perl6
You can’t perform that action at this time.
0 commit comments