/** * Builds a new {@link CatchClause} instance. * * @param exceptionTypeName the exception type name * @param caughtExceptionName the local name for the caught exception * @param stmts the statements to add to the catch clause * @return a new catch clause */ public CatchClause catch0( String exceptionTypeName, String caughtExceptionName, Statement... stmts) { final CatchClause cc = ast.newCatchClause(); final SingleVariableDeclaration svd = ast.newSingleVariableDeclaration(); svd.setType(newSimpleType(exceptionTypeName)); svd.setName(ast.newSimpleName(caughtExceptionName)); cc.setException(svd); final Block block = ast.newBlock(); addAll(statements(block), stmts); cc.setBody(block); return cc; }
public CatchClause newCatchClause(String type, String name, Block catchBlock) { CatchClause catchClause = ast.newCatchClause(); catchClause.setException(newVariableDecl(name, type)); catchClause.setBody(catchBlock); return catchClause; }