public void showexception(PyException exc) { // Should probably add code to handle skipping top stack frames // somehow... Py.printException(exc); }
public static void printException(Throwable t) { printException(t, null, null); }
public static void printException(Throwable t, PyFrame f) { printException(t, f, null); }
public void printStackTrace() { Py.printException(this); }
private static void runModule(InteractiveConsole interp, String moduleName, boolean set_argv0) { // PEP 338 - Execute module as a script try { PyObject runpy = imp.importName("runpy", true); PyObject runmodule = runpy.__findattr__("_run_module_as_main"); runmodule.__call__(Py.newStringOrUnicode(moduleName), Py.newBoolean(set_argv0)); } catch (Throwable t) { Py.printException(t); interp.cleanup(); System.exit(-1); } }
public void run() { Py.setSystemState(systemState); try { func.__call__(args); } catch (PyException exc) { if (exc.match(Py.SystemExit) || exc.match(_systemrestart.SystemRestart)) { return; } Py.stderr.println("Unhandled exception in thread started by " + func); Py.printException(exc); } }
public void callExitFunc() throws PyIgnoreMethodTag { PyObject exitfunc = __findattr__("exitfunc"); if (exitfunc != null) { try { exitfunc.__call__(); } catch (PyException exc) { if (!exc.match(Py.SystemExit)) { Py.println(stderr, Py.newString("Error in sys.exitfunc:")); } Py.printException(exc); } } Py.flushLine(); }
/** * A convenience function for PyProxys. */ public PyObject _jcallexc(Object[] args) throws Throwable { try { return __call__(Py.javas2pys(args)); } catch (PyException e) { if (e.value.getJavaProxy() != null) { Object t = e.value.__tojava__(Throwable.class); if (t != null && t != Py.NoConversion) { throw (Throwable) t; } } else { ThreadState ts = Py.getThreadState(); if (ts.frame == null) { Py.maybeSystemExit(e); } if (Options.showPythonProxyExceptions) { Py.stderr.println( "Exception in Python proxy returning to Java:"); Py.printException(e); } } throw e; } }
runJar(opts.filename); } catch (Throwable t) { Py.printException(t); System.exit(-1); interp.execfile(System.in, "<stdin>"); } catch (Throwable t) { Py.printException(t); Py.printException(t); interp.cleanup(); System.exit(-1); interp.exec(opts.command); } catch (Throwable t) { Py.printException(t); System.exit(1); Py.printException(t);