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

Only print error message once when formatting error output #116

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-116.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Only print error message once when formatting error output
links:
- https://github.com/palantir/gradle-failure-reports/pull/116
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public static String formatThrowableWithMessage(Throwable throwable, String erro
"%s\n\n%s\n%s\n\n%s\n%s",
errorMessage,
CAUSAL_CHAIN,
causalChain,
causalChain.replace(errorMessage, ""),
EXCEPTION_MESSAGE,
Throwables.getStackTraceAsString(throwable));
Throwables.getStackTraceAsString(throwable).replace(errorMessage, ""));
}

public static String printThrowableCause(Throwable throwableCause) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public void exception_with_suggestion_provides_error_with_suggestion() {
.startsWith(EXCEPTION_MESSAGE
+ "\n\n* Causal chain is:\n\t"
+ "com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: "
+ EXCEPTION_MESSAGE + "\n\n* Full exception is:\n"
+ "com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: "
+ EXCEPTION_MESSAGE);
+ "\n\n* Full exception is:\n"
+ "com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: ");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public void canFormatHeader() {
public void canFormatThrowable() {
assertThat(ThrowableResources.formatThrowable(new GradleException("lock out of date")))
.contains("* Causal chain is:\n"
+ "\torg.gradle.api.GradleException: lock out of date\n\n"
+ "\torg.gradle.api.GradleException: \n\n"
+ "* Full exception is:\n"
+ "org.gradle.api.GradleException: lock out of date");
+ "org.gradle.api.GradleException: ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Caused by: java.lang.OutOfMemoryError

* Causal chain is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':throwExceptionWithSuggestedFix'.
com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: ExceptionWithSuggestedFixMessage
com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion:

* Full exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':throwExceptionWithSuggestedFix'.
Caused by: com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: ExceptionWithSuggestedFixMessage
Caused by: com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion:
</failure>
</testcase>
</testsuite>
Expand All @@ -33,11 +33,11 @@ Caused by: com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion

* Causal chain is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':myProject:throwGradleException'.
org.gradle.api.GradleException: This is a normal gradle exception
org.gradle.api.GradleException:

* Full exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':myProject:throwGradleException'.
Caused by: org.gradle.api.GradleException: This is a normal gradle exception
Caused by: org.gradle.api.GradleException:
</failure>
</testcase>
</testsuite>
Expand All @@ -48,13 +48,13 @@ Caused by: org.gradle.api.GradleException: This is a normal gradle exception
* Causal chain is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':myProject:throwInnerExceptionWithSuggestedFix'.
org.gradle.api.GradleException: OuterGradleException
com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: InnerExceptionWithSuggestedFixMessage
com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion:
java.lang.RuntimeException: InnerRuntimeException

* Full exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':myProject:throwInnerExceptionWithSuggestedFix'.
Caused by: org.gradle.api.GradleException: OuterGradleException
Caused by: com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion: InnerExceptionWithSuggestedFixMessage
Caused by: com.palantir.gradle.failurereports.exceptions.ExceptionWithSuggestion:
... PLACEHOLDER_NUMBER more
Caused by: java.lang.RuntimeException: InnerRuntimeException
... PLACEHOLDER_NUMBER more
Expand Down