try {
scriptEngine.eval(new FileReader(mortgageRulesFile));
} catch (ScriptException se) {
// Re-throw exception unless it's our early-exit exception.
if (se.getMessage() == null ||
!se.getMessage().contains("ScriptEarlyExitException")
) {
throw se;
}
// Set script result message if early-exit exception embedded.
Throwable t = se.getCause();
while (t != null) {
if (t instanceof ScriptEarlyExitException) {
scriptResult.setMessage(t.getMessage());
break;
}
t = t.getCause();
}
}
return scriptResult;