Exception handling - Factor Documentation (original) (raw)
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:
Words for establishing an error handler:
cleanup ( try cleanup-always cleanup-error -- )
recover ( ..a try: ( ..a -- ..b ) recovery: ( ..a error -- ..b ) -- ..b )
ignore-errors ( ... quot: ( ... -- ... ) -- ... )
Syntax sugar for defining errors:
Unhandled errors are reported in the listener and can be debugged using various tools. See The debugger. Restartable errors
The debugger
Post-mortem error inspection
Common error handling pitfalls
When Factor encounters a critical error, it calls the following word: