File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ = begin pod
2
+
3
+ = TITLE class Failure
4
+
5
+ class Failure { }
6
+
7
+ A C < Failure > is a I < soft > or I < unthrown > exception, usually generated by
8
+ calling C < &fail > . It acts as a wrapper around an L < Exception > object.
9
+
10
+ Sink (void) context causes a Failure to throw, i.e. turn into a normal
11
+ exception.
12
+
13
+ Checking a Failure for truth (with the C < Bool > method) or definedness (with
14
+ the C < defined > method) marks the failure as handled, and causes it not to
15
+ throw in sink context anymore.
16
+
17
+ You can call the C < handled > method to check if a failure has been handled.
18
+
19
+ Calling methods on unhandled failures propagates the failure. The
20
+ specification says the result is another C < Failure > , in Rakudo it causes the
21
+ failure to throw.
22
+
23
+ = head1 Methods
24
+
25
+ = head2 handled
26
+
27
+ method handled(Failure:D:) returns Bool:D
28
+
29
+ Returns C < True > for handled failures, C < False > otherwise.
30
+
31
+ = head2 exception
32
+
33
+ method handled(Failure:D:) returns Exception
34
+
35
+ Returns the L < Exception > object that the failure wraps.
36
+
37
+ = head2 Bool
38
+
39
+ multi method Bool(Failure:D:) returns Bool:D
40
+
41
+ Returns C < False > , and marks the failure as handled.
42
+
43
+ = head2 defined
44
+
45
+ multi method defined(Failure:D:) returns Bool:D
46
+
47
+ Returns C < False > (failures are officially undefined), and marks
48
+ the failure as handled.
49
+
50
+ = end pod
You can’t perform that action at this time.
0 commit comments