Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ public Connection getConnection() throws JdbcClientException {
Thread.currentThread().setContextClassLoader(this.classLoader);
conn = dataSource.getConnection();
} catch (Exception e) {
String errorMessage = String.format("Can not connect to jdbc due to error: %s, Catalog name: %s",
e.getMessage(), this.getCatalogName());
String errorMessage = String.format(
"Catalog `%s` can not connect to jdbc due to error: %s",
this.getCatalogName(), JdbcClientException.getAllExceptionMessages(e));
throw new JdbcClientException(errorMessage, e);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,19 @@ private static Object[] escapePercentInArgs(Object... args) {
}
return escapedArgs;
}

public static String getAllExceptionMessages(Throwable throwable) {
StringBuilder sb = new StringBuilder();
while (throwable != null) {
String message = throwable.getMessage();
if (message != null && !message.isEmpty()) {
if (sb.length() > 0) {
sb.append(" | Caused by: ");
}
sb.append(message);
}
throwable = throwable.getCause();
}
return sb.toString();
}
}