Function: catch key thunk handler
Invoke
thunkin the dynamic context ofhandlerfor exceptions matchingkey. If thunk throws to the symbolkey, thenhandleris invoked this way:(handler key args ...)
keymay be a symbol. Thethunktakes no arguments. Ifthunkreturns normally, that is the return value ofcatch.Handler is invoked outside the scope of its own
catch. Ifhandleragain throws to the same key, a new handler from further up the call chain is invoked.If the key is
#t, then a throw to any symbol will match this call tocatch.
Function: throw key &rest args ...
Invoke the catch form matching
key, passingargsto thehandler.If the key is a symbol it will match catches of the same symbol or of #t.
If there is no handler at all, an error is signaled.
procedure: error message args ...
Raise an error with key
misc-errorand a message constructed by displayingmsgand writingargs. This normally prints a stack trace, and brings you back to the top level, or exits kawa if you are not running interactively. This procedure is part of SRFI-23, and other Scheme implementations.
Function: primitive-throw exception
Throws the
exception, which must be an instance of a sub-class of<java.lang.Throwable>.
Syntax: try-finally body handler
Evaluate
body, and return its result. However, before it returns, evaluatehandler. Even ifbodyreturns abnormally (by throwing an exception),handleris evaluated.(This is implemented just like Java's
try-finally.)
Syntax: try-catch body handler ...
Evaluate
body, in the context of the givenhandlerspecifications. Eachhandlerhas the form:vartypeexp...If an exception is thrown in
body, the firsthandleris selected such that the thrown exception is an instance of thehandler'stype. If nohandleris selected, the exception is propagated through the dynamic execution context until a matchinghandleris found. (If no matchinghandleris found, then an error message is printed, and the computation terminated.)Once a
handleris selected, thevaris bound to the thrown exception, and theexpin thehandlerare executed. The result of thetry-catchis the result ofbodyif no exception is thrown, or the value of the lastexpin the selectedhandlerif an exception is thrown.(This is implemented just like Java's
try-catch.)
Function: dynamic-wind in-guard thunk out-guard
All three arguments must be 0-argument procedures. First calls
in-guard, thenthunk, thenout-guard. The result of the expression is that ofthunk. Ifthunkis exited abnormally (by throwing an exception or invoking a continuation),out-guardis called.If the continuation of the dynamic-wind is re-entered (which is not yet possible in Kawa), the
in-guardis called again.This function was added in R5RS.