Any special exception-handling would look like this:
(on-err
(fn ()
#|do stuff...|#)
(fn (e)
(if (isa e 'MyExceptionType)
(let reason (rep e)
#|handle according to reason|#)
; unknown error, rethrow:
(err e))))
In fact, I have a draft implementation of 'on-err and 'err for arc2c:
(set on-err
(fn (f fh)
(ccc
(fn (k)
; let tmp (%curr-err)
((fn (tmp)
; set up a continuation guard
(%cont-guard-up)
(%set-err
(fn (e)
; tear down continuation guard
; and current error handler
(%cont-guard-down)
(%set-err tmp)
; so that if fh throws, it throws
; on the original err instead of
; recursing
(k (fh e)) ))
(f)
; tear down continuation guard and
; reset error handler
(%cont-guard-down)
(%set-err tmp))
(%curr-err))))))
(set err
(fn (e)
((%curr-err) e)))
(%set-err
(fn (e)
(%pr "Error of type: ")
(%prn (%type e))
(%pr "Error: ")
(%prn (%rep e))
(%halt)))
%curr-err and %set-err would have to set a thread-local variable in the C-side. %cont-guard-up and %cont-guard-down just need to set up continuation guards.