Recover from errors with Common Lisp conditions and restarts

8 steps · about 1 h 57 min · Intermediate

  1. 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.

  2. 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.

  3. Read how the condition system is organised (reference, Common Lisp HyperSpec, 15 min)

    Explains signalling, handlers and restarts as the standard defines them.

  4. Define your own condition classes (reference, Common Lisp HyperSpec, 10 min)

    Shows slots, readers and :report for custom conditions.

  5. 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.

  6. 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.

  7. 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.

  8. 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.