Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwrap or skip InvocationTargetException when printing build errors #18424

Open
vlsi opened this issue Sep 27, 2021 · 4 comments
Open

Unwrap or skip InvocationTargetException when printing build errors #18424

vlsi opened this issue Sep 27, 2021 · 4 comments
Labels
a:feature A new functionality in:problems problems api

Comments

@vlsi
Copy link
Contributor

vlsi commented Sep 27, 2021

Expected Behavior

Gradle should not print InvocationTargetException since it is not really a user-facing exception. It is used by Java as a marker for the reflection-induced exceptions.

However, InvocationTargetException adds virtually zero extra information, and in 99.42% of the cases the right thing is to print the cause of InvocationTargetException.

Suggested behavior:

if (topLevelException instanceof InvocationTargetException
    && topLevelException.getCause() != null
    && topLevelException.getSuppressed().isEmpty()) {
    topLevelException = topLevelException.getCause()
}

Here's one of the cases when ignoring InvocationTargetException would make things easier to understand: #13862
The message would change from InvocationTargetException (no error message) to NoSuchMethodException: com.gradle.scan.plugin.internal.d.d.$deserializeLambda$(java.lang.invoke.SerializedLambda)


#17462

InvocationTargetException (no error message) would become AnnotationProcessingError: java.lang.NoClassDefFoundError: javax/annotation/Generated

and so on.

Current Behavior

Currently, Gradle might print the following message

* What went wrong:
Execution failed for task ':core-data:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Sample code: https://github.com/JetBrains/kotlin/blob/12d31adbc49e0cbb588643aa962a716b043f26c2/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptWithoutKotlincTask.kt#L285

The code calls Method#invoke, so InvocationTargetException might be thrown as a result.

Context

@vlsi vlsi added a:feature A new functionality to-triage labels Sep 27, 2021
@vlsi
Copy link
Contributor Author

vlsi commented Sep 27, 2021

@mlopatkin, sorry for pinging you directly, however, I see you investigated #17462 earlier. WDYT if Gradle prints the cause instead of InvocationTargetException?

@ljacomet ljacomet added in:problems problems api and removed to-triage labels Sep 27, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@github-actions github-actions bot added the stale label Sep 27, 2022
@vlsi
Copy link
Contributor Author

vlsi commented Sep 27, 2022

I think this is still relevant.

@github-actions github-actions bot removed the stale label Sep 27, 2022
@ov7a ov7a added the to-triage label Oct 5, 2023
@ov7a
Copy link
Member

ov7a commented Oct 5, 2023

Sorry for the late reply.

Thank you for your interest in Gradle!

This feature request is in the backlog of the relevant team, but this area of Gradle is currently not in focus. It might take a while before it gets implemented.

@ov7a ov7a removed the to-triage label Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:problems problems api
Projects
None yet
Development

No branches or pull requests

3 participants