Skip to content

Commit

Permalink
Minor, make query response with "Unknown error" if exception without …
Browse files Browse the repository at this point in the history
…message occurs
  • Loading branch information
nichunen authored and shaofengshi committed May 27, 2018
1 parent 398401f commit 2b1e9f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -123,6 +123,9 @@ public static String makeErrorMsgUserFriendly(Throwable e) {
}

public static String makeErrorMsgUserFriendly(String errorMsg) {
if (errorMsg == null) {
return "Unknown error.";
}
try {
// make one line
errorMsg = errorMsg.replaceAll("\\s", " ");
Expand Down
Expand Up @@ -225,4 +225,10 @@ public void testRemoveCommentInSql() {
Assert.assertEquals(originSql, QueryUtil.removeCommentInSql(sqlWithComment));
}
}

@Test
public void testUnknownErrorResponseMessage() {
String msg = QueryUtil.makeErrorMsgUserFriendly(new NullPointerException());
Assert.assertEquals("Unknown error.", msg);
}
}

0 comments on commit 2b1e9f4

Please sign in to comment.