private Result resolveToFoundResult(PluginResolver effectivePluginResolver, PluginRequest request) {
Result result = new Result(request);
try {
effectivePluginResolver.resolve(request, result);
} catch (Exception e) {
throw new LocationAwareException(
new GradleException(String.format("Error resolving plugin %s", request.getDisplayName()), e),
request.getScriptSource(), request.getLineNumber());
}
if (!result.isFound()) {
String message = buildNotFoundMessage(request, result);
Exception exception = new UnknownPluginException(message);
throw new LocationAwareException(exception, request.getScriptSource(), request.getLineNumber());
}
return result;
}