TryExp extends StandaloneExp { public void addCatch(Class<?> catchClass, StandaloneExp catchExp) { catchClauses.add(new CatchClause(catchClass, catchExp)); } TryExp(StandaloneExp body); void addFinally(StandaloneExp finallyExp); void addCatch(Class<?> catchClass, StandaloneExp catchExp); @Override String getCode(); NestedExp getCatchClauseVar(int num);  }
@Test public void testAddCatch() { TryExp exp = new TryExp(new IfExp(BooleanExp.TRUE)); exp.addCatch(Throwable.class, new IfExp(BooleanExp.TRUE)); assertEquals("\ntry {\nif (true) {\n}\n} catch (java.lang.Throwable e1) {\nif (true) {\n}\n}", exp.getCode()); }