racket/collects/ssax/catch-errors.ss
2005-05-27 18:56:37 +00:00

16 lines
347 B
Scheme

(module catch-errors mzscheme
(provide failed?)
(define-syntax failed?
(syntax-rules ()
((failed? stmts ...)
(thunk-failed? (lambda () stmts ...)))))
(define (thunk-failed? thunk)
(call-with-current-continuation
(lambda (return)
(with-handlers
(((lambda (x) #t) (lambda (exn) #t)))
(thunk)
#f)))))