Skip to content

Commit

Permalink
refactor(apollo-client): Optimize the exception message when failing …
Browse files Browse the repository at this point in the history
…to retrieve configuration information. (#22)

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

* chore(changes): Update CHANGES.md

* chore(apollo-java): Streamlined code
  • Loading branch information
klboke authored Mar 17, 2023
1 parent b6cc06a commit 78ec538
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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,16 @@ public static String getDetailMessage(Throwable ex) {
counter--;
continue;
}
builder.append(" [Cause: ").append(cause.getMessage());
builder.append(" [Cause: ")
.append(cause.getClass().getSimpleName())
.append("(")
.append(cause.getMessage())
.append(")");
}

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

return builder.toString();
}

}
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

0 comments on commit 78ec538

Please sign in to comment.