(define (with-handler handler proc) (call-with-current-continuation (lambda (esc) (proc (lambda (reason) (call-with-current-continuation (lambda (restart) (esc (handler reason restart))))))))) (with-handler (lambda (reason restart) (if (eq? reason 'failure) (begin (display "Something went wrong") (newline)) (restart #f))) (lambda (throw) (display "1") (newline) (display "2") (newline) (throw 'annoyed) (display "3") (newline) (display "4") (newline) (throw 'failure) (display "5") (newline) (display "6") (newline)))