Handbook
Glossary
cleanup ( try cleanup-always cleanup-error -- )
Factor handbook
»
The language
»
Exception handling
Prev:
rethrow ( error -- * )
Next:
recover ( ..a try: ( ..a -- ..b ) recovery: ( ..a error -- ..b ) -- ..b )
Vocabulary
continuations
Inputs
try
a
quotation
with stack effect
( ..a -- ..a )
cleanup-always
a
quotation
with stack effect
( ..a -- ..b )
cleanup-error
a
quotation
with stack effect
( ..b -- ..b )
Outputs
None
Word description
Calls the
try
quotation. If no error is thrown, calls
cleanup-always
without restoring the data stack. If an error is thrown, restores the data stack, calls
cleanup-always
followed by
cleanup-error
, and rethrows the error.
See also
recover
,
finally
Definition
USING:
kernel
;
IN:
continuations
:
cleanup
( try cleanup-always cleanup-error -- )
[
compose
[
dip
rethrow
]
curry
recover
]
[
drop
]
2bi
call
;
inline