This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Problem with primitive-throw?
- From: Chris Dean <ctdean at sokitomi dot com>
- To: dominique dot boucher at nuecho dot com
- Cc: "'Kawa List'" <kawa at sources dot redhat dot com>
- Date: Fri, 20 Feb 2004 07:34:58 -0800
- Subject: Problem with primitive-throw?
- References: <000701c3f7c1$a230c5c0$6400a8c0@Forman>
> When I try to compile this piece of code:
>
> (try-catch
> (begin
> (format (current-error-port) "Testing ...~%")
> (primitive-throw (make <java.lang.RuntimeException> "test")))
> (exc <java.lang.Throwable>
> (format (current-error-port) "an error occurred!~%")))
>
> I get the following error:
A work around is to throw the exception in a separate function:
% cat Foo.scm
(define (throw-error)
(primitive-throw (make <java.lang.RuntimeException> "test")))
(define (foo)
(try-catch
(begin
(format (current-error-port) "Testing ...~%")
(throw-error))
(exc <java.lang.Throwable>
(format (current-error-port) "an error occurred!~%"))))
(foo)
% java kawa.repl --main -C Foo.scm
(compiling Foo.scm)
% java Foo
Testing ...
an error occurred!
Regards,
Chris Dean