Skip to content

Commit 1e58b51

Browse files
committed
Improve error message for unsupported connection mode (sentinel)
1 parent 7ac1805 commit 1e58b51

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

driver/src/main/java/jdbc/RedisConnection.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ public void checkMode() throws SQLException {
4444
}
4545
RedisMode clientMode = client.getMode();
4646
if (clientMode != serverMode) {
47+
String clientModeName = toLowerCase(clientMode.name());
48+
String serverModeName = toLowerCase(serverMode.name());
4749
String serverURLPrefix = RedisClientFactory.getURLPrefix(serverMode);
48-
String urlFix = serverURLPrefix != null ? String.format("\nPlease change the URL prefix to \"%s\".", serverURLPrefix) : null;
49-
throw new SQLException(String.format("The connection mode \"%s\" does not match the server mode \"%s\".%s",
50-
toLowerCase(clientMode.name()), toLowerCase(serverMode.name()), urlFix));
50+
String messageTail = serverURLPrefix != null
51+
? String.format("Please change the URL prefix to \"%s\".", serverURLPrefix)
52+
: String.format("Meanwhile, the connection mode \"%s\" is not supported at the moment.", serverModeName);
53+
throw new SQLException(String.format("The connection mode \"%s\" does not match the server mode \"%s\".\n%s",
54+
clientModeName, serverModeName, messageTail));
5155
}
5256
}
5357

0 commit comments

Comments
 (0)