Skip to content

Commit de0a844

Browse files
authored
SketchRunner: Redirect all errors to PDE console (#212)
* SketchRunner: Redirect all errors to PDE console Signed-off-by: Ce Gao <[email protected]> * RLangPApplet: Remove the code about = Signed-off-by: Ce Gao <[email protected]>
1 parent 591cc12 commit de0a844

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/rprocessing/RLangPApplet.java

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public void prePassCode() {
106106
SEXP source = RParser.parseSource(this.programText + "\n", "inline-string");
107107
if (isSameClass(source, ExpressionVector.class)) {
108108
ExpressionVector ev = (ExpressionVector) source;
109+
// Stores the expressions except size().
109110
List<SEXP> sexps = new ArrayList<SEXP>();
110111
for (int i = ev.length() - 1; i >= 0; --i) {
111112
if (isSameClass(ev.get(i), FunctionCall.class)
@@ -116,6 +117,7 @@ && isSameClass(((FunctionCall) ev.get(i)).getFunction(), Symbol.class)) {
116117
sexps.add(ev.get(i));
117118
} else if (((Symbol) ((FunctionCall) ev.get(i)).getFunction()).getPrintName()
118119
.equals(Constant.SIZE_NAME)) {
120+
// size function is defined in global namespace.
119121
log("size function is defined in global namespace.");
120122
hasSize = true;
121123
sizeFunction = ev.get(i);

src/rprocessing/mode/run/SketchRunner.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import processing.core.PConstants;
99
import rprocessing.Runner;
1010
import rprocessing.SketchPositionListener;
11-
import rprocessing.exception.REvalException;
1211
import rprocessing.exception.RMIRuntimeException;
1312
import rprocessing.exception.RSketchError;
1413
import rprocessing.mode.RLangMode;
@@ -132,12 +131,7 @@ public void sketchMoved(final Point leftTop) {
132131
modeService.handleSketchException(id, exception);
133132
} catch (final Exception exception) {
134133
log("Sketch runner caught Exception:" + exception);
135-
if (exception.getCause() != null && exception.getCause() instanceof REvalException) {
136-
modeService.handleSketchException(id,
137-
convertREvalError((REvalException) exception.getCause()));
138-
} else {
139-
modeService.handleSketchException(id, exception);
140-
}
134+
modeService.handleSketchException(id, convertREvalError(exception));
141135
} finally {
142136
log("Handling sketch stoppage...");
143137
modeService.handleSketchStopped(id);
@@ -228,8 +222,8 @@ private static void startSketchRunner(final String id) throws RMIRuntimeExceptio
228222
}
229223
}
230224

231-
private static void launch(final String id, final ModeService modeService) throws RMIProblem,
232-
RemoteException {
225+
private static void launch(final String id, final ModeService modeService)
226+
throws RMIProblem, RemoteException {
233227
final SketchRunner sketchRunner = new SketchRunner(id, modeService);
234228
final SketchService stub = (SketchService) RMIUtils.export(sketchRunner);
235229
log("Calling mode's handleReady().");
@@ -247,7 +241,7 @@ public void run() {
247241
}));
248242
}
249243

250-
private SketchException convertREvalError(final REvalException exception) {
244+
private SketchException convertREvalError(final Exception exception) {
251245
return new SketchException(exception.getMessage());
252246
}
253247
}

0 commit comments

Comments
 (0)