use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class IncludedBuildArtifactBuilder method contextualizeFailure.
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;
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method wrapsContextualMultiCauseExceptionWithLocationAwareException.
@Test
public void wrapsContextualMultiCauseExceptionWithLocationAwareException() {
Throwable cause1 = new ContextualException();
Throwable cause2 = new ContextualException();
Throwable failure = new ContextualMultiCauseException(cause1, cause2);
Throwable transformedFailure = analyser().transform(failure);
assertThat(transformedFailure, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformedFailure;
assertThat(gse.getCause(), sameInstance(failure));
assertThat(gse.getReportableCauses(), equalTo(toList(cause1, cause2)));
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method wrapsHighestContextualExceptionWithLocationAwareException.
@Test
public void wrapsHighestContextualExceptionWithLocationAwareException() {
Throwable cause = new ContextualException();
Throwable failure = new ContextualException(cause);
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(), equalTo(toList(cause)));
}
use of org.gradle.internal.exceptions.LocationAwareException in project gradle by gradle.
the class DefaultExceptionAnalyserTest method addsLocationInfoFromDeepestCause.
@Test
public void addsLocationInfoFromDeepestCause() {
RuntimeException cause = new RuntimeException();
ContextualException failure = new ContextualException(new RuntimeException(cause));
failure.setStackTrace(toArray(otherElement, callerElement));
cause.setStackTrace(toArray(element, otherElement, 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 wrapsOriginalExceptionWhenItIsNotAContextualException.
@Test
public void wrapsOriginalExceptionWhenItIsNotAContextualException() {
Throwable failure = new RuntimeException();
DefaultExceptionAnalyser analyser = analyser();
Throwable transformed = analyser.transform(failure);
assertThat(transformed, instanceOf(LocationAwareException.class));
LocationAwareException gse = (LocationAwareException) transformed;
assertThat(gse.getCause(), sameInstance(failure));
assertThat(gse.getReportableCauses(), isEmpty());
}
Aggregations