From: <le...@us...> - 2009-08-06 20:17:17
|
Revision: 6634 http://jython.svn.sourceforge.net/jython/?rev=6634&view=rev Author: leosoto Date: 2009-08-06 20:17:09 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Handle exceptions when running a JAR file through -jar cmdline switch. Fixes http://bugs.jython.org/issue1405 Modified Paths: -------------- trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2009-08-06 05:10:26 UTC (rev 6633) +++ trunk/jython/src/org/python/util/jython.java 2009-08-06 20:17:09 UTC (rev 6634) @@ -70,6 +70,18 @@ public static boolean shouldRestart; + /** + * Runs a JAR file, by executing the code found in the file __run__.py, + * which should be in the root of the JAR archive. + * + * Note that the __name__ is set to the base name of the JAR file and not + * to "__main__" (for historic reasons). + * + * This method do NOT handle exceptions. the caller SHOULD handle any + * (Py)Exceptions thrown by the code. + * + * @param filename The path to the filename to run. + */ public static void runJar(String filename) { // TBD: this is kind of gross because a local called `zipfile' just magically // shows up in the module's globals. Either `zipfile' should be called @@ -201,7 +213,12 @@ } Py.getSystemState().path.insert(0, new PyString(path)); if (opts.jar) { - runJar(opts.filename); + try { + runJar(opts.filename); + } catch (Throwable t) { + Py.printException(t); + System.exit(-1); + } } else if (opts.filename.equals("-")) { try { interp.locals.__setitem__(new PyString("__file__"), new PyString("<stdin>")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |