Skip to content

Commit 6d0cfe4

Browse files
committed
doc resuming of exceptions
1 parent f6854ec commit 6d0cfe4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

doc/Language/exceptions.pod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ C<throw> can be viewed as the method form of C<die>, just that in this
150150
particular case, the sub and method forms of the routine have different
151151
names.
152152
153+
=head2 Resuming of Exceptions
154+
155+
Exceptions interrupt control flow and divert it away from the statement
156+
following the statement that threw it. Any exception handled by the
157+
user can be resumed and control flow will continue with the statement
158+
following the statement that threw the exception. To do so call the
159+
method C<.resume> on the exception object.
160+
161+
CATCH { when X::AdHoc { .resume } } # this is step 2
162+
163+
die "We leave control after this."; # this is step 1
164+
165+
say "We have continued with control flow."; # this is step 3
166+
153167
=end pod
154168

155169
# vim: expandtab shiftwidth=4 ft=perl6

doc/Type/Exception.pod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ Usage:
6363
6464
Throws the exception.
6565
66+
=head2 method resume
67+
68+
Resumes control flow where C<.throw> left it when handled in a C<CATCH> block.
69+
70+
Defined as:
71+
72+
method resume(Exception:D:)
73+
74+
Usage:
75+
76+
CATCH { default { .resume } }
77+
6678
=head2 method rethrow
6779
6880
Defined as:

0 commit comments

Comments
 (0)