picrin/t/exception.scm

33 lines
551 B
Scheme
Raw Normal View History

(import (scheme base)
(scheme write))
2013-11-17 03:43:03 -05:00
(define (print obj)
(write obj)
(newline)
obj)
(print
2013-11-17 03:25:26 -05:00
(call/cc
(lambda (k)
(with-exception-handler
(lambda (x)
(write "condition: ")
(write x)
(newline)
(k 'exception))
(lambda ()
(+ 1 (raise 'an-error)))))))
2013-11-17 03:43:03 -05:00
(print
(with-exception-handler
(lambda (con)
(cond
((string? con)
(print con))
(else
(print "a warning has been issued")))
42)
(lambda ()
(+ (raise-continuable "should be a number")
23))))