racket/collects/meta/drdr/retry.rkt
2011-06-28 02:01:41 -04:00

17 lines
520 B
Racket

#lang racket
(require "notify.rkt")
(define-syntax-rule (retry-until-success msg expr ...)
(retry-until-success* msg (lambda () expr ...)))
(define (retry-until-success* msg thunk)
(notify! msg)
(thunk)
#;(with-handlers ([exn:fail? (lambda (x)
((error-display-handler) (format "Error trying to: ~a: ~a" msg (exn-message x)) x)
(notify! "Retrying...")
(retry-until-success* msg thunk))])
(thunk)))
(provide retry-until-success)