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

IDEA doesn't show failure's root cause immediately #161

Open
VsevolodGolovanov opened this issue Jul 8, 2020 · 3 comments
Open

IDEA doesn't show failure's root cause immediately #161

VsevolodGolovanov opened this issue Jul 8, 2020 · 3 comments

Comments

@VsevolodGolovanov
Copy link

VsevolodGolovanov commented Jul 8, 2020

Maven 3.3.1, GMavenPlus 1.8.1, IDEA 2020.1.3.

I need to fail the build with an explanation. So I do:

throw new RuntimeException("This is the REAL problem");

This is what I see in Intellij's IDEA Run window after running the build:
image
No mention of my exception or its message. I have to click the run configuration name and find it there:
image

This may seem trivial, but still.

  1. Why is it like this? Is it IDEA that decides to only show the first sentence? Maybe replace the dot with another colon then? (I know, ideally IDEA would report errors better, but they have much more pressing issues that go unsolved for years, so I doubt it's realistic.)
  2. I don't necessarily expect the whole stack there, but it doesn't even mention my RuntimeException, mentions the useless InvocationTargetException instead - skip it.
@VsevolodGolovanov
Copy link
Author

Maybe there is a better way to fail the build?

I tried log.error+System.exit, but it's hardly an improvement.

@keeganwitt
Copy link
Member

It has to do with how exceptions get bubbled up through Maven (that and the fact it's a bit obscured because I'm using reflection). Here is where that wrapping exception comes from within GMavenPlus. I'm open to suggestions if you have a better idea.

I haven't used this feature before, but here's an idea

<configuration>
  <scripts>
    <script><![CDATA[session.result.addException(new RuntimeException("Some reason"))]]></script>
  </scripts>
</configuration>

@VsevolodGolovanov
Copy link
Author

VsevolodGolovanov commented Jul 13, 2020

Tried doing session.result.addException - it doesn't stop the build. If I stop it by throwing an exception or with System.exit then the added exception doesn't show up in the log or IDEA messages.

I get that the InvocationTargetException wrapper is the immediate cause of MojoExecutionException, and that's why maven logs it.
I don't know, maybe unwrap it if InvocationTargetException's cause is a RuntimeException? A bit hacky, but could be an improvement...

I'm not still not clear about 1 - how IDEA decides what to show in that Failed to execute goal item. I thought it just parses maven's output as text. But when I changed ExecuteMojo like this:

} catch (InvocationTargetException e) {
    throw new MojoExecutionException("Error occurred while calling a method on a Groovy class from classpath. FakeException: and it's message.", e);

IDEA showed this:
image
So it didn't filter it out. Seems like it's more than parsing text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants