Class GradleException
- All Implemented Interfaces:
Serializable, org.gradle.internal.exceptions.ResolutionProvider
- Direct Known Subclasses:
BuildCancelledException, CircularReferenceException, ConfigurationCycleException, org.gradle.internal.exceptions.DefaultMultiCauseException, DuplicateFileCopyingException, org.gradle.process.internal.ExecException, GradleScriptException, IllegalDependencyNotation, InvalidActionClosureException, InvalidModelException, InvalidModelRuleDeclarationException, InvalidModelRuleException, InvalidPluginException, InvalidUserCodeException, InvalidUserDataException, ManifestException, ModelInstantiationException, ModelRuleBindingException, PluginInstantiationException, PublishException, ReadOnlyModelViewException, ReportContainer.ImmutableViolationException, ResourceException, StopActionException, TaskInstantiationException, TestExecutionException, UnknownDomainObjectException, UnknownModelException, VerificationException, WriteOnlyModelViewException
Implements ResolutionProvider as of Gradle 9.9, to make it simple to provide a list of resolutions
for any exception.
Deliberately calls super(X, Y, Z...) constructors instead of using a telescoping constructor pattern,
since passing an explicit null cause counts as initializing it, which makes any later
Throwable.initCause(Throwable) call throw IllegalStateException.
Resolutions are tracked as an internal, mutable list, so that nested catch blocks can provide and modify resolutions with additional context.
- Since:
- 0.7
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newGradleException.GradleException(String message) Creates a newGradleException.GradleException(String message, @Nullable Throwable cause) Creates a newGradleException.GradleException(String message, @Nullable Throwable cause, Iterable<String> resolutions) Creates a newGradleExceptioncarrying the given resolution suggestions. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResolution(String resolution) Adds a potential resolution to this exception.voidClears the resolutions from this exception.Gets the resolutions.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
GradleException
public GradleException()Creates a newGradleException.- Since:
- 0.7
-
GradleException
-
GradleException
-
GradleException
@Incubating public GradleException(String message, @Nullable Throwable cause, Iterable<String> resolutions) Creates a newGradleExceptioncarrying the given resolution suggestions.There is deliberately no
(String, Iterable)overload. It would makenew GradleException(message, null)ambiguous withGradleException(String, Throwable): Java and Kotlin would reject such a call at compile time, and Groovy, which resolves overloads from the runtime types, would select the resolutions constructor and fail on the null. To attach resolutions without a cause, useGradleException(String)followed byaddResolution(String).Note that passing a
nullcause here still counts as initializing it, so a laterThrowable.initCause(Throwable)call on the result throwsIllegalStateException.- Since:
- 9.9.0
-
-
Method Details
-
addResolution
Adds a potential resolution to this exception.- Since:
- 9.9.0
-
clearResolutions
-
getResolutions
Gets the resolutions.This is left non-
finalto allowDefaultMultiCauseExceptionto override it.- Specified by:
getResolutionsin interfaceorg.gradle.internal.exceptions.ResolutionProvider- Since:
- 9.9.0
-