private void applyPlugin(PluginRequest request, String id, Runnable applicator) {
try {
try {
applicator.run();
} catch (UnknownPluginException e) {
throw new InvalidPluginException(
String.format(
"Could not apply requested plugin %s as it does not provide a plugin with id '%s'."
+ " This is caused by an incorrect plugin implementation."
+ " Please contact the plugin author(s).",
request, id
),
e
);
} catch (Exception e) {
throw new InvalidPluginException(String.format("An exception occurred applying plugin request %s", request), e);
}
} catch (Exception e) {
throw new LocationAwareException(e, request.getScriptSource(), request.getLineNumber());
}
}