Created
May 4, 2021 20:26
-
-
Save motersen/ac088cecd2582243961c7d3e57cf6cb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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