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

refactor(apollo-client): Optimize the exception message when failing to retrieve configuration information. #22

Merged
merged 3 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Release Notes.
Apollo Java 2.2.0

------------------

[refactor(apollo-client): Optimize the exception message when failing to retrieve configuration information.](https://github.com/apolloconfig/apollo-java/pull/22)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo-java/milestone/2?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,19 @@ public static String getDetailMessage(Throwable ex) {
counter--;
continue;
}
builder.append(" [Cause: ").append(cause.getMessage());
builder.append(" [Cause: ")
.append(getThrowingClassName(cause))
klboke marked this conversation as resolved.
Show resolved Hide resolved
.append("(")
.append(cause.getMessage())
.append(")");
}

builder.append(Strings.repeat("]", counter));

return builder.toString();
}

public static String getThrowingClassName(Throwable throwable) {
return throwable.getClass().getSimpleName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void testGetDetailMessageWithCauses() throws Exception {
String causeMsg2 = "another cause";
String someMessage = "some message";

Throwable cause2 = new Throwable(causeMsg2);
Throwable cause2 = new Exception(causeMsg2);
Throwable cause1 = new Throwable(causeMsg1, cause2);
Throwable ex = new Throwable(someMessage, cause1);

String expected = someMessage + " [Cause: " + causeMsg1 + " [Cause: " + causeMsg2 + "]]";
String expected = someMessage + " [Cause: Throwable("+ causeMsg1 +") [Cause: Exception(" + causeMsg2 + ")]]";
assertEquals(expected, ExceptionUtil.getDetailMessage(ex));
}

Expand Down