private void addExceptionHandler(Class<?> exceptionClass) {
// Generate a Block corresponding to:
// throw new RTForeignFunctionException(RTValue.generateForeignFunctionErrorMessage(exception, generatedClassName, supercombinatorName), null, exception);
JavaTypeName exceptionType = JavaTypeName.make(exceptionClass);
JavaExpression args[] = new JavaExpression [4];
JavaTypeName argTypes[] = new JavaTypeName [4];
args[0] = new LocalVariable("caught_exception" , exceptionType);
argTypes[0] = JavaTypeName.THROWABLE;
args[1] = LiteralWrapper.make(CALToJavaNames.createFullClassNameFromSC(getQualifiedName(), module));
argTypes[1] = JavaTypeName.STRING;
args[2] = LiteralWrapper.make(currentModuleName.toSourceText());
argTypes[2] = JavaTypeName.STRING;
args[3] = LiteralWrapper.make(getFunctionName());
argTypes[3] = JavaTypeName.STRING;
MethodInvocation genMessage = new MethodInvocation.Static (JavaTypeNames.RTVALUE,
"generateForeignFunctionErrorMessage",
args,
argTypes,
argTypes[1]);
JavaExpression constructorArgs[] = new JavaExpression [2];
JavaTypeName constructorArgTypes[] = new JavaTypeName [2];
constructorArgs[0] = genMessage;
constructorArgTypes[0] = JavaTypeName.STRING;
constructorArgs[1] = new LocalVariable("caught_exception", exceptionType);
constructorArgTypes[1] = JavaTypeName.THROWABLE;