本文整理汇总了Java中org.gradle.internal.exceptions.LocationAwareException类的典型用法代码示例。如果您正苦于以下问题:Java LocationAwareException类的具体用法?Java LocationAwareException怎么用?Java LocationAwareException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LocationAwareException类属于org.gradle.internal.exceptions包,在下文中一共展示了LocationAwareException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findDeepestRootException
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
private Throwable findDeepestRootException(Throwable exception) {
// TODO: fix the way we work out which exception is important: TaskExecutionException is not always the most helpful
Throwable locationAware = null;
Throwable result = null;
Throwable contextMatch = null;
for (Throwable current = exception; current != null; current = current.getCause()) {
if (current instanceof LocationAwareException) {
locationAware = current;
} else if (current instanceof GradleScriptException || current instanceof TaskExecutionException) {
result = current;
} else if (contextMatch == null && current.getClass().getAnnotation(Contextual.class) != null) {
contextMatch = current;
}
}
if (locationAware != null) {
return locationAware;
} else if (result != null) {
return result;
} else if (contextMatch != null) {
return contextMatch;
} else {
return exception;
}
}
示例2: resolveToFoundResult
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
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.getScriptDisplayName(), request.getLineNumber());
}
if (!result.isFound()) {
String message = buildNotFoundMessage(request, result);
Exception exception = new UnknownPluginException(message);
throw new LocationAwareException(exception, request.getScriptDisplayName(), request.getLineNumber());
}
return result;
}
示例3: contextualizeFailure
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
private RuntimeException contextualizeFailure(BuildIdentifier buildId, ReportedException e) {
if (e.getCause() instanceof LocationAwareException) {
LocationAwareException lae = (LocationAwareException) e.getCause();
IncludedBuildArtifactException wrappedCause = new IncludedBuildArtifactException("Failed to build artifacts for " + buildId, lae.getCause());
LocationAwareException newLae = new LocationAwareException(wrappedCause, lae.getSourceDisplayName(), lae.getLineNumber());
return new ReportedException(newLae);
}
return e;
}
示例4: listPluginRequests
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
public List<PluginRequest> listPluginRequests() {
List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() {
public PluginRequest transform(DependencySpecImpl original) {
return new DefaultPluginRequest(original.id, original.version, original.apply, original.lineNumber, scriptSource);
}
});
ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() {
public PluginId transform(PluginRequest pluginRequest) {
return pluginRequest.getId();
}
});
// Check for duplicates
for (PluginId key : groupedById.keySet()) {
List<PluginRequest> pluginRequestsForId = groupedById.get(key);
if (pluginRequestsForId.size() > 1) {
PluginRequest first = pluginRequests.get(0);
PluginRequest second = pluginRequests.get(1);
InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber());
throw new LocationAwareException(exception, second.getScriptDisplayName(), second.getLineNumber());
}
}
return pluginRequests;
}
示例5: testGetUserFriendlyError
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
@Test
public void testGetUserFriendlyError() {
String causeMsg = "failed to find target current";
RuntimeException rootCause = new IllegalStateException(causeMsg);
String locationMsg = "Build file '~/project/build.gradle' line: 86";
RuntimeException locationError = new RuntimeException(locationMsg, rootCause) {
@NotNull
@Override
public String toString() {
return LocationAwareException.class.getName() + ": " + super.toString();
}
};
Throwable error = new Throwable(locationError);
//noinspection ThrowableResultOfMethodCallIgnored
RuntimeException realCause = myErrorHandler.getUserFriendlyError(error, myProjectPath, null);
assertTrue(realCause instanceof LocationAwareExternalSystemException);
LocationAwareExternalSystemException locationAwareExternalSystemException = (LocationAwareExternalSystemException)realCause;
assertEquals("~/project/build.gradle", locationAwareExternalSystemException.getFilePath());
assertEquals(Integer.valueOf(-1), locationAwareExternalSystemException.getColumn());
assertEquals(Integer.valueOf(86), locationAwareExternalSystemException.getLine());
}
示例6: resolveToFoundResult
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
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;
}
示例7: extractCauses
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
private void extractCauses(Throwable failure, List<Throwable> causes) {
if (failure instanceof MultipleBuildFailures) {
MultipleBuildFailures exception = (MultipleBuildFailures) failure;
for (Throwable componentFailure : exception.getCauses()) {
extractCauses(componentFailure, causes);
}
} else if (failure instanceof LocationAwareException) {
causes.addAll(((LocationAwareException) failure).getReportableCauses());
} else {
causes.add(failure);
}
}
示例8: assertHasNoCause
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
public ExecutionFailure assertHasNoCause() {
if (failure instanceof LocationAwareException) {
LocationAwareException exception = (LocationAwareException) failure;
assertThat(exception.getReportableCauses(), isEmpty());
} else {
assertThat(failure.getCause(), nullValue());
}
outputFailure.assertHasNoCause();
return this;
}
示例9: getGradleExceptionMessage
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
/**
* This code was copied from BuildExceptionReporter.reportBuildFailure in gradle's source, then modified slightly to compensate for the fact that we're not driven by options or logging things to a
* logger object.
*/
public static String getGradleExceptionMessage(Throwable failure, ShowStacktrace stackTraceLevel) {
if (failure == null) {
return "";
}
Formatter formatter = new Formatter();
formatter.format("%nBuild failed.%n");
if (stackTraceLevel == ShowStacktrace.INTERNAL_EXCEPTIONS) {
formatter.format("Use the stack trace options to get more details.");
}
formatter.format("%n");
if (failure instanceof LocationAwareException) {
LocationAwareException scriptException = (LocationAwareException) failure;
formatter.format("%s%n%n", scriptException.getLocation());
formatter.format("%s", scriptException.getCause().getMessage());
for (Throwable cause : scriptException.getReportableCauses()) {
formatter.format("%nCause: %s", getMessage(cause));
}
} else {
formatter.format("%s", getMessage(failure));
}
if (stackTraceLevel != ShowStacktrace.INTERNAL_EXCEPTIONS) {
formatter.format("%n%nException is:\n");
if (stackTraceLevel == ShowStacktrace.ALWAYS_FULL) {
return formatter.toString() + getStackTraceAsText(failure);
}
return formatter.toString() + getStackTraceAsText(StackTraceUtils.deepSanitize(failure));
}
return formatter.toString();
}
示例10: transform
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
public Throwable transform(Throwable exception) {
Throwable actualException = findDeepestRootException(exception);
if (actualException instanceof LocationAwareException) {
return actualException;
}
ScriptSource source = null;
Integer lineNumber = null;
// TODO: remove these special cases
if (actualException instanceof ScriptCompilationException) {
ScriptCompilationException scriptCompilationException = (ScriptCompilationException) actualException;
source = scriptCompilationException.getScriptSource();
lineNumber = scriptCompilationException.getLineNumber();
}
if (source == null) {
for (
Throwable currentException = actualException; currentException != null;
currentException = currentException.getCause()) {
for (StackTraceElement element : currentException.getStackTrace()) {
if (element.getLineNumber() >= 0 && scripts.containsKey(element.getFileName())) {
source = scripts.get(element.getFileName());
lineNumber = element.getLineNumber();
break;
}
}
}
}
return new LocationAwareException(actualException, source, lineNumber);
}
示例11: getRequests
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
public List<PluginRequest> getRequests() {
List<PluginRequest> pluginRequests = collect(specs, new Transformer<PluginRequest, DependencySpecImpl>() {
public PluginRequest transform(DependencySpecImpl original) {
return new DefaultPluginRequest(original.id, original.version, original.lineNumber, scriptSource);
}
});
ListMultimap<PluginId, PluginRequest> groupedById = CollectionUtils.groupBy(pluginRequests, new Transformer<PluginId, PluginRequest>() {
public PluginId transform(PluginRequest pluginRequest) {
return pluginRequest.getId();
}
});
// Check for duplicates
for (PluginId key : groupedById.keySet()) {
List<PluginRequest> pluginRequestsForId = groupedById.get(key);
if (pluginRequestsForId.size() > 1) {
PluginRequest first = pluginRequests.get(0);
PluginRequest second = pluginRequests.get(1);
InvalidPluginRequestException exception = new InvalidPluginRequestException(second, "Plugin with id '" + key + "' was already requested at line " + first.getLineNumber());
throw new LocationAwareException(exception, second.getScriptSource(), second.getLineNumber());
}
}
return pluginRequests;
}
示例12: transform
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
public Throwable transform(Throwable exception) {
Throwable actualException = findDeepestRootException(exception);
if (actualException instanceof LocationAwareException) {
return actualException;
}
ScriptSource source = null;
Integer lineNumber = null;
// TODO: remove these special cases
if (actualException instanceof ScriptCompilationException) {
ScriptCompilationException scriptCompilationException = (ScriptCompilationException) actualException;
source = scriptCompilationException.getScriptSource();
lineNumber = scriptCompilationException.getLineNumber();
}
if (source == null) {
for (
Throwable currentException = actualException; currentException != null;
currentException = currentException.getCause()) {
for (StackTraceElement element : currentException.getStackTrace()) {
if (scripts.containsKey(element.getFileName())) {
source = scripts.get(element.getFileName());
lineNumber = element.getLineNumber() >= 0 ? element.getLineNumber() : null;
break;
}
}
}
}
return new LocationAwareException(actualException, source, lineNumber);
}
示例13: extractCauses
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
private void extractCauses(Throwable failure, List<Throwable> causes) {
if (failure instanceof MultipleBuildFailures) {
MultipleBuildFailures exception = (MultipleBuildFailures) failure;
for (Throwable componentFailure : exception.getCauses()) {
extractCauses(componentFailure, causes);
}
} else if (failure instanceof LocationAwareException) {
causes.addAll(((LocationAwareException) failure).getReportableCauses());
} else {
causes.add(failure.getCause());
}
}
示例14: getGradleExceptionMessage
import org.gradle.internal.exceptions.LocationAwareException; //导入依赖的package包/类
/**
* This code was copied from BuildExceptionReporter.reportBuildFailure in gradle's source, then modified slightly to compensate for the fact that we're not driven by options or logging things to a
* logger object.
*/
public static String getGradleExceptionMessage(Throwable failure, ShowStacktrace stackTraceLevel) {
if (failure == null) {
return "";
}
Formatter formatter = new Formatter();
formatter.format("%nBuild failed.%n");
if (stackTraceLevel == ShowStacktrace.INTERNAL_EXCEPTIONS) {
formatter.format("Use the stack trace options to get more details.");
}
if (failure != null) {
formatter.format("%n");
if (failure instanceof LocationAwareException) {
LocationAwareException scriptException = (LocationAwareException) failure;
formatter.format("%s%n%n", scriptException.getLocation());
formatter.format("%s", scriptException.getCause().getMessage());
for (Throwable cause : scriptException.getReportableCauses()) {
formatter.format("%nCause: %s", getMessage(cause));
}
} else {
formatter.format("%s", getMessage(failure));
}
if (stackTraceLevel != ShowStacktrace.INTERNAL_EXCEPTIONS) {
formatter.format("%n%nException is:\n");
if (stackTraceLevel == ShowStacktrace.ALWAYS_FULL) {
return formatter.toString() + getStackTraceAsText(failure);
}
return formatter.toString() + getStackTraceAsText(StackTraceUtils.deepSanitize(failure));
}
}
return formatter.toString();
}