Skip to content

Commit 5bbb1dd

Browse files
committed
Generated operations no longer catch exceptions internally
They now pass them up to the step that called perform so that it can handle it. Closes #250
1 parent dae807c commit 5bbb1dd

1 file changed

Lines changed: 24 additions & 51 deletions

File tree

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

0 commit comments

Comments
 (0)