This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

trouble handling exceptions


Hello!

I am trying to execute some Scheme code in the Kawa-1.7 interpreter
through a controlling Java program.  The Scheme code lives in a .scm
file which is loaded into the interpreter.  It would be very convenient
to be able to use exceptions to communicate certain events occuring in
the Scheme code up to the controlling Java method.  The naive way of
doing this is through code like the following:

	Scheme scheme = new Scheme()
	Environment.setCurrent(scheme.getEnvironment());
	try {
		scheme.eval("(load 'filename.scm)");
	}
	catch (Throwable e)
	{
		...
	}

The only problem is that this doesn't work.  It seems that any
exceptions raised by the Scheme code in filename.scm are caught
somewhere in the Kawa interpreter and are not propagated up to the next
level.  It turns out that this seems be a general issue with the (load)
function.  I am completely unable to catch any exceptions raised in the
loaded code, even from the Kawa interpreter command line.  So code like
this seems to fail as well:

	(try-catch
		(load 'filename.scm)
		(e <java.lang.Exception>
			...))

This generates an exception trace like the following:

#<ERROR my-exception>
        at kawa.standard.throw_name.applyN(throw_name.java:21)
        at gnu.mapping.Procedure.apply(Procedure.java:102)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:258)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
        at kawa.Shell.run(Shell.java:232)
        at kawa.standard.load.loadSource(load.java:162)
        at kawa.standard.load.loadSource(load.java:131)
        at kawa.standard.load.apply(load.java:233)
        at kawa.standard.load.apply2(load.java:201)
        at kawa.standard.load.apply1(load.java:191)
        at atInteractiveLevel.apply(Unknown Source)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:258)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:188)
        at kawa.Shell.run(Shell.java:232)
        at kawa.Shell.run(Shell.java:180)
        at kawa.Shell.run(Shell.java:167)
        at kawa.Shell.run(Shell.java:154)
        at kawa.repl.main(repl.java:609)

And then returns to the Kawa interpreter prompt.  The (try-catch) does
not seem to be executed.

Is there a better way to catch these exceptions being generated in the
loaded file?  Is what I'm trying to do even possible in the Kawa
implementation?  I will appreciate any suggestions.

--DaveH		"Be Excellent to each other!"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]