Kawa supports the exception framework and forms from R6RS and R7RS. See Exceptions for details.
You can also work with native Java exceptions at a low level.
primitive-throw procedure throws a
It is implemented just like Java’s
(primitive-throw (java.lang.IndexOutOfBoundsException "bad index"))
You can catch an exception with the
try-catch syntax. For example:
(try-catch (do-a-bunch-of-stuff) (ex java.lang.Throwable (format #f "caught ~a~%~!" ex) (exit)))
try-finally does the obvious:
(define (call-with-port port proc) (try-finally (proc port) (close-port port)))
expression forms that can return values, while the corresponding
Java forms are statements that cannot return values.