Skip to content

Commit 66fafc9

Browse files
committed
Merge pull request #335 from JLLeitschuh/fix/generatorNotPassingExceptionsToUI
Fix/generator not passing exceptions to ui
2 parents 0fac7bf + 567c772 commit 66fafc9

File tree

2 files changed

+31
-53
lines changed

2 files changed

+31
-53
lines changed

buildSrc/src/main/java/edu/wpi/gripgenerator/templates/Operation.java

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -190,76 +190,49 @@ private List<Statement> getPerformExpressionList(String inputParamId, String out
190190
List<Statement> performStatement = expressionList.stream().map(ExpressionStmt::new).collect(Collectors.toList());
191191
final String exceptionVariable = "e";
192192
final String outputSocketForEachVariableId = "outputSocket";
193-
final TryStmt performTry = new TryStmt(
194-
new BlockStmt(
195-
Arrays.asList(
193+
194+
performStatement.addAll(
195+
Arrays.asList(
196196
/* Make the operation function call */
197-
new ExpressionStmt(
198-
getFunctionCallExpression()
199-
),
197+
new ExpressionStmt(
198+
getFunctionCallExpression()
199+
),
200200
/*
201201
* Afterwards iterate over all of the output sockets and call setValue using the value
202202
* stored.
203203
*/
204-
new ForeachStmt(
205-
new VariableDeclarationExpr(
206-
0,
207-
ASTHelper.createReferenceType("OutputSocket", 0),
208-
Collections.singletonList(
209-
new VariableDeclarator(
210-
new VariableDeclaratorId(outputSocketForEachVariableId)
211-
)
212-
)
213-
),
214-
new NameExpr(outputParamId),
215-
new BlockStmt(
216-
Collections.singletonList(
217-
new ExpressionStmt(
218-
new MethodCallExpr(
219-
new NameExpr(outputSocketForEachVariableId),
220-
"setValueOptional",
221-
Collections.singletonList(
222-
new MethodCallExpr(
223-
new NameExpr(outputSocketForEachVariableId),
224-
"getValue"
225-
)
226-
)
227-
)
228-
)
204+
new ForeachStmt(
205+
new VariableDeclarationExpr(
206+
0,
207+
ASTHelper.createReferenceType("OutputSocket", 0),
208+
Collections.singletonList(
209+
new VariableDeclarator(
210+
new VariableDeclaratorId(outputSocketForEachVariableId)
229211
)
230212
)
231-
)
232-
)
233-
),
234-
Collections.singletonList(
235-
new CatchClause(
236-
new MultiTypeParameter(
237-
ModifierSet.FINAL,
238-
null,
239-
Collections.singletonList(
240-
ASTHelper.createReferenceType("Exception", 0)
241-
),
242-
new VariableDeclaratorId(exceptionVariable)
243213
),
214+
new NameExpr(outputParamId),
244215
new BlockStmt(
245-
// TODO: Add some sort of indication that an error has occurred
246216
Collections.singletonList(
247217
new ExpressionStmt(
248218
new MethodCallExpr(
249-
new NameExpr(exceptionVariable),
250-
"printStackTrace"
219+
new NameExpr(outputSocketForEachVariableId),
220+
"setValueOptional",
221+
Collections.singletonList(
222+
new MethodCallExpr(
223+
new NameExpr(outputSocketForEachVariableId),
224+
"getValue"
225+
)
226+
)
251227
)
252228
)
253229
)
254230
)
255231
)
256-
),
257-
null
232+
)
258233
);
259-
// This is needed to prevent a null pointer
260-
performTry.setResources(Collections.emptyList());
261234

262-
performStatement.add(performTry);
235+
263236
return performStatement;
264237
}
265238

ui/src/main/java/edu/wpi/grip/ui/components/ExceptionWitnessResponderButton.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,13 @@ private void assignFromExceptionEvent(ExceptionEvent event) {
107107
errorMessage.setText(errorMessageText);
108108
if (event.getException().isPresent()) {
109109
final Exception exception = event.getException().get();
110-
stackTrace.setText(Throwables.getStackTraceAsString(exception));
111-
stackTrace.setVisible(true);
110+
final String exceptionMessage = Throwables.getStackTraceAsString(exception);
111+
// Otherwise it is impossible to scroll the text field because it is updated so frequently
112+
if (!exceptionMessage.equals(stackTrace.getText())) {
113+
stackTrace.setText(exceptionMessage);
114+
}
115+
116+
stackTracePane.setVisible(true);
112117
} else {
113118
stackTracePane.setVisible(false);
114119
stackTrace.setText("");

0 commit comments

Comments
 (0)