Exception handling
Factor handbook » The language

Prev:Objects
Next:Deterministic resource disposal


Support for handling exceptional situations such as bad user input, implementation bugs, and input/output errors is provided by a set of words built using continuations.

Two words raise an error in the innermost error handler for the current dynamic extent:
Image
throw ( error -- * )

Image
rethrow ( error -- * )


Words for establishing an error handler:
Image
cleanup ( try cleanup-always cleanup-error -- )

Image
recover ( ..a try: ( ..a -- ..b ) recovery: ( ..a error -- ..b ) -- ..b )

Image
ignore-errors ( ... quot: ( ... -- ... ) -- ... )


Syntax sugar for defining errors:
Image
ERROR:


Unhandled errors are reported in the listener and can be debugged using various tools. See The debugger.
Image Restartable errors
Image The debugger
Image Post-mortem error inspection
Image Common error handling pitfalls

When Factor encounters a critical error, it calls the following word:
Image
die ( -- )