if(result==null) {
// this can only happen on an InterpreterCancelledException, i.e. NEVER ;-)
return null;
}
if (result.getException() != null) {
throw new ScriptExecutionException(result.getException().getMessage(), result.getException());
}
return result.getResult();
} catch(Throwable e) {
if(e instanceof ScriptExecutionException) {
throw (ScriptExecutionException) e;
} else {
throw new ScriptExecutionException("An error occured during the script execution: " + e.getMessage(), e);
}
}
} else {
throw new ScriptExecutionException("Script does not contain any expression");
}
}