diff --git a/lib/Failure.pod b/lib/Failure.pod new file mode 100644 index 000000000..7db9eac7e --- /dev/null +++ b/lib/Failure.pod @@ -0,0 +1,50 @@ +=begin pod + +=TITLE class Failure + + class Failure { } + +A C is a I or I exception, usually generated by +calling C<&fail>. It acts as a wrapper around an L object. + +Sink (void) context causes a Failure to throw, i.e. turn into a normal +exception. + +Checking a Failure for truth (with the C method) or definedness (with +the C method) marks the failure as handled, and causes it not to +throw in sink context anymore. + +You can call the C method to check if a failure has been handled. + +Calling methods on unhandled failures propagates the failure. The +specification says the result is another C, in Rakudo it causes the +failure to throw. + +=head1 Methods + +=head2 handled + + method handled(Failure:D:) returns Bool:D + +Returns C for handled failures, C otherwise. + +=head2 exception + + method handled(Failure:D:) returns Exception + +Returns the L object that the failure wraps. + +=head2 Bool + + multi method Bool(Failure:D:) returns Bool:D + +Returns C, and marks the failure as handled. + +=head2 defined + + multi method defined(Failure:D:) returns Bool:D + +Returns C (failures are officially undefined), and marks +the failure as handled. + +=end pod