use of spoon.reflect.code.CtThrow in project Ex2Amplifier by STAMP-project.
the class MainGenerator method addCatchGivenExceptionToTry.
private static void addCatchGivenExceptionToTry(CtTypeReference exceptionType, Factory factory, CtTry aTry, String suffixNameException) {
final CtCatch aCatch = factory.createCatch();
final CtCatchVariable catchVariable = factory.createCatchVariable();
catchVariable.setSimpleName("__exceptionEx2Amplifier" + suffixNameException);
catchVariable.setType(exceptionType);
aCatch.setParameter(catchVariable);
final CtThrow aThrow = factory.createThrow();
aThrow.setThrownExpression(factory.createConstructorCall(factory.Type().createReference("java.lang.RuntimeException"), factory.createVariableRead(factory.createCatchVariableReference(catchVariable), false)));
aCatch.setBody(aThrow);
aTry.addCatcher(aCatch);
}
Aggregations