From: <bc...@wo...> - 2001-11-10 15:57:28
|
[Sebastien Delafond] >Hi, > >I have a very dummy Jython script, except.py, that does : > >except.py : >1: import java.lang.Exception >2: raise java.lang.Exception > >I then compile this to a standalone jar (jythonc --core --jar except.jar >except.py), that I call from another Java class; the call itself looks like >: > >try { > String jar = "./except.jar"; > URLClassLoader theLoader = new URLClassLoader(new URL[] { new URL("file:" >+ jar)}); > Object theLoadedClass = Class.forName("except", true, >theLoader).newInstance(); > String[] array = new String[] {}; > Method main = theLoadedClass.getClass(). > getMethod("main", new Class[] { array.getClass() }); > main.invoke(theLoadedClass, new Object[] {new String[] {}}); >} >catch (Throwable t) { > t.printStackTrace(); >} [A sidenote: when using the URLClassLoader I can't find the except$_PyInner class. I'll add a bugreport about that.] >The problem is that my "catch" actually doesn't catch the Exception I'm >throwing/raising from the jython script. It is because of the catch in Py.runMain(..): > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jython/jython/org/python/core/Py.java?annotate=2.53#824 >... > >Thanks for any input, since I seem to be missing something obvious : I just >would like to be able to catch the exceptions raised from the python script, >in the java caller. I'm sure that's doable :) Not at the moment. I'll submit a bugreport. regards, finn |