Skip to content

Commit

Permalink
SketchRunner: Redirect all errors to PDE console (#212)
Browse files Browse the repository at this point in the history
* SketchRunner: Redirect all errors to PDE console

Signed-off-by: Ce Gao <ce.gao@outlook.com>

* RLangPApplet: Remove the code about =

Signed-off-by: Ce Gao <ce.gao@outlook.com>
  • Loading branch information
gaocegege authored Aug 12, 2017
1 parent 591cc12 commit de0a844
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/rprocessing/RLangPApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void prePassCode() {
SEXP source = RParser.parseSource(this.programText + "\n", "inline-string");
if (isSameClass(source, ExpressionVector.class)) {
ExpressionVector ev = (ExpressionVector) source;
// Stores the expressions except size().
List<SEXP> sexps = new ArrayList<SEXP>();
for (int i = ev.length() - 1; i >= 0; --i) {
if (isSameClass(ev.get(i), FunctionCall.class)
Expand All @@ -116,6 +117,7 @@ && isSameClass(((FunctionCall) ev.get(i)).getFunction(), Symbol.class)) {
sexps.add(ev.get(i));
} else if (((Symbol) ((FunctionCall) ev.get(i)).getFunction()).getPrintName()
.equals(Constant.SIZE_NAME)) {
// size function is defined in global namespace.
log("size function is defined in global namespace.");
hasSize = true;
sizeFunction = ev.get(i);
Expand Down
14 changes: 4 additions & 10 deletions src/rprocessing/mode/run/SketchRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import processing.core.PConstants;
import rprocessing.Runner;
import rprocessing.SketchPositionListener;
import rprocessing.exception.REvalException;
import rprocessing.exception.RMIRuntimeException;
import rprocessing.exception.RSketchError;
import rprocessing.mode.RLangMode;
Expand Down Expand Up @@ -132,12 +131,7 @@ public void sketchMoved(final Point leftTop) {
modeService.handleSketchException(id, exception);
} catch (final Exception exception) {
log("Sketch runner caught Exception:" + exception);
if (exception.getCause() != null && exception.getCause() instanceof REvalException) {
modeService.handleSketchException(id,
convertREvalError((REvalException) exception.getCause()));
} else {
modeService.handleSketchException(id, exception);
}
modeService.handleSketchException(id, convertREvalError(exception));
} finally {
log("Handling sketch stoppage...");
modeService.handleSketchStopped(id);
Expand Down Expand Up @@ -228,8 +222,8 @@ private static void startSketchRunner(final String id) throws RMIRuntimeExceptio
}
}

private static void launch(final String id, final ModeService modeService) throws RMIProblem,
RemoteException {
private static void launch(final String id, final ModeService modeService)
throws RMIProblem, RemoteException {
final SketchRunner sketchRunner = new SketchRunner(id, modeService);
final SketchService stub = (SketchService) RMIUtils.export(sketchRunner);
log("Calling mode's handleReady().");
Expand All @@ -247,7 +241,7 @@ public void run() {
}));
}

private SketchException convertREvalError(final REvalException exception) {
private SketchException convertREvalError(final Exception exception) {
return new SketchException(exception.getMessage());
}
}

0 comments on commit de0a844

Please # to comment.