Recover from errors with Common Lisp conditions and restarts
8 steps · about 1 h 57 min · Intermediate
- Follow a log parser that recovers from bad entries (tutorial, Practical Common Lisp, 35 min)
Builds one worked example that splits signalling, handling and recovery across layers.
- Try the handling and restart recipes at the REPL (tutorial, Common Lisp Cookbook, 25 min)
Short runnable snippets for ignore-errors, handler-case, handler-bind and restarts.
- Read how the condition system is organised (reference, Common Lisp HyperSpec, 15 min)
Explains signalling, handlers and restarts as the standard defines them.
- Define your own condition classes (reference, Common Lisp HyperSpec, 10 min)
Shows slots, readers and :report for custom conditions.
- Signal a condition without forcing an error (reference, Common Lisp HyperSpec, 8 min)
Separates signal, which can be ignored, from error, which must be handled.
- Handle conditions in place with handler-bind (reference, Common Lisp HyperSpec, 10 min)
Runs the handler before the stack unwinds, which is what makes restarts possible.
- Choose a recovery path with invoke-restart (reference, Common Lisp HyperSpec, 8 min)
Lets a high-level handler pick a restart offered by low-level code.
- Offer a quick skip option with with-simple-restart (reference, Common Lisp HyperSpec, 6 min)
The shortest way to give users and handlers a named way out.