use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method usesDeepestScriptExceptionException.
@Test
public void usesDeepestScriptExceptionException() {
Throwable cause = new GradleScriptException("broken", new RuntimeException());
Throwable failure = new GradleScriptException("broken", new RuntimeException(cause));
Throwable transformedFailure = analyser().transform(failure);
assertThat(transformedFailure, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformedFailure;
assertThat(gse.getCause(), sameInstance(cause));
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method doesNotAddLocationWhenLocationCannotBeDetermined.
@Test
public void doesNotAddLocationWhenLocationCannotBeDetermined() {
Throwable failure = new ContextualException();
Throwable transformedFailure = analyser().transform(failure);
assertThat(transformedFailure, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformedFailure;
assertThat(gse.getSourceDisplayName(), nullValue());
assertThat(gse.getLineNumber(), nullValue());
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method addsLocationInfoFromDeepestStackFrameWithMatchingSourceFileAndLineInformation.
@Test
public void addsLocationInfoFromDeepestStackFrameWithMatchingSourceFileAndLineInformation() {
Throwable failure = new ContextualException();
failure.setStackTrace(toArray(elementWithNoSourceFile, elementWithNoLineNumber, otherElement, element, callerElement));
DefaultExceptionAnalyser analyser = analyser();
notifyAnalyser(analyser, source);
Throwable transformedFailure = analyser.transform(failure);
assertThat(transformedFailure, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformedFailure;
assertThat(gse.getSourceDisplayName(), equalTo(source.getDisplayName()));
assertThat(gse.getLineNumber(), equalTo(7));
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method wrapsContextualExceptionWithLocationAwareException.
@Test
public void wrapsContextualExceptionWithLocationAwareException() {
Throwable failure = new ContextualException();
DefaultExceptionAnalyser analyser = analyser();
Throwable transformedFailure = analyser.transform(failure);
assertThat(transformedFailure, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformedFailure;
assertThat(gse.getCause(), sameInstance(failure));
assertThat(gse.getReportableCauses(), isEmpty());
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultPluginRequestApplicator method resolveToFoundResult.
private Result resolveToFoundResult(PluginResolver effectivePluginResolver, PluginRequestInternal 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;
}
Aggregations