Traditionally, if an error occurred, the error message and the possible solution were provided to the console via a single String in the corresponding exception.
That meant possible solutions for Problems could be scattered all over the console output.
To improve the user experience, we introduced a new way to provide suggestions.
The idea is to provide a list of suggestions for a problem in the console output.
The suggestions are displayed in the separate "Try"- section of the console output.
The suggestions are collected in the BuildExceptionReporter
and printed to the console.
In some cases, you still want to keep the old behavior and display the suggestions in the error message.
- To add a custom suggestion in the "Try" section of the console output, your exception needs to implement the
ResolutionProvider
interface. - That should be it. The suggestion will be displayed in the "Try" section.
For some scenarios, it doesn't make sense to display all the generic suggestions we currently have.
E.g. --stacktrace
for a compilation error is not helpful.
To influence the generic suggestions Gradle displays, the NonGradleCause interface was introduced.
If an exception implements this interface, Gradle will not display the --stacktrace
option.
Another more targeted interface is CompilationFailedIndicator
.
This interface is used to indicate that the exception is caused by a compilation failure.
This will not show the --stacktrace
option, but it will show the --info
option since this can help with parameters passed to the compiler.