Skip to content

Instantly share code, notes, and snippets.

@motersen
Created May 4, 2021 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motersen/ac088cecd2582243961c7d3e57cf6cb2 to your computer and use it in GitHub Desktop.
Save motersen/ac088cecd2582243961c7d3e57cf6cb2 to your computer and use it in GitHub Desktop.
(define-condition always-error (error) ())
(defun always-fail ()
(restart-case
(progn
(format t "Trying...~%")
(signal 'always-error))
(retry ()
(always-fail))))
(defun make-handler (&optional (retries 2))
(lambda (condition)
(when (typep condition 'always-error)
(if (<= retries 0)
(format t "Failed...~%")
(progn
(decf retries)
(invoke-restart 'retry))))))
(handler-bind ((always-error (make-handler)))
(always-fail))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment