Skip to content

Commit

Permalink
clean up runtime behavior around syntax errors and other exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Feinberg committed Aug 30, 2010
1 parent 272657c commit fe9a45e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions runtime/src/jycessing/PAppletJythonDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.python.core.PyException;
import org.python.core.PyObject;
import org.python.core.PyStringMap;
import org.python.core.PySyntaxError;
import org.python.util.InteractiveConsole;

import processing.core.PApplet;
Expand Down Expand Up @@ -68,10 +69,18 @@ abstract public class PAppletJythonDriver extends PApplet {
// the source file name, so that errors have the file name instead of
// "<string>"
private void interpretSketch() {
Py.setSystemState(interp.getSystemState());
Py.exec(Py.compile_flags(programText, pySketchPath, CompileMode.exec,
new CompilerFlags()), interp.getLocals(), null);
Py.flushLine();
try {
Py.setSystemState(interp.getSystemState());
Py.exec(Py.compile_flags(programText, pySketchPath,
CompileMode.exec, new CompilerFlags()), interp.getLocals(),
null);
Py.flushLine();
} catch (Throwable t) {
while (t.getCause() != null)
t = t.getCause();
t.printStackTrace(System.err);
System.exit(-1);
}
}

public PAppletJythonDriver(final InteractiveConsole interp,
Expand Down
1 change: 0 additions & 1 deletion runtime/src/jycessing/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ public static void runSketch(final String[] args, final String sketchPath,
PApplet.runSketch(args, applet);
} catch (Throwable t) {
Py.printException(t);
throw new RuntimeException(t);
} finally {
interp.cleanup();
}
Expand Down

0 comments on commit fe9a45e

Please sign in to comment.