Guard|guard_«intercept_»«ensure_»

Definitions:

expression phrase ⇒ []→⊤, list phrase ⇒ (([⊥]→⊤)*), list phrase ⇒ (([]→⊤)?)
Source: /avail/Avail/Foundation/Exceptions
Categories: Exception Handling, Control Structures
Execute body. If an exception is raised, the virtual machine will scan the current fiber 's chain of continuation s to identify invocations of this primitive. The continuation nearest to the end of the continuation chain, i.e., closest to the raise of the exception, that defines a handler that accepts an argument of the correct type is invoked with the exception. So an exception handler will potentially run if code run (directly or indirectly) by body raises an exception of the accepted type.

Whether body succeeds or is curtailed by an exception, always apply unwind. This is a safe place to clean up an algorithm after it runs or fails. If one of the handlers is invoked, then it will run after the handler runs, even if the handler raises its own exception.

Position Name Type Description
Parameters
1 bodyPhrase expression phrase ⇒ []→⊤ The protected function.
2 handlersPhrase list phrase ⇒ (([⊥]→⊤)*) A list of exception handlers.
3 optionalUnwindPhrase list phrase ⇒ (([]→⊤)?) If specified, then a function to apply after either the successful completion of body or an unwind through this continuation.
Returns send phrase ⇒ ⊤

Semantic restrictions:

[]→⊤'s type, <[⊥]→⊤…|>'s type, ([]→⊤)?'s type
Source: /avail/Avail/Foundation/Exceptions
Reject the current parse if 1) any of the exception handlers aren't or 2) any earlier handlers hide later handlers (by having a more general type).
Type Description
Parameter Types
[]→⊤'s type
<[⊥]→⊤…|>'s type
([]→⊤)?'s type