From 1e58b510dfff1d05f99113f509c5d21480600cb3 Mon Sep 17 00:00:00 2001 From: Anna Rodionova Date: Sat, 2 Mar 2024 17:14:51 +0100 Subject: [PATCH] Improve error message for unsupported connection mode (sentinel) --- driver/src/main/java/jdbc/RedisConnection.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/driver/src/main/java/jdbc/RedisConnection.java b/driver/src/main/java/jdbc/RedisConnection.java index 3a4bd13..1c730cf 100644 --- a/driver/src/main/java/jdbc/RedisConnection.java +++ b/driver/src/main/java/jdbc/RedisConnection.java @@ -44,10 +44,14 @@ public void checkMode() throws SQLException { } RedisMode clientMode = client.getMode(); if (clientMode != serverMode) { + String clientModeName = toLowerCase(clientMode.name()); + String serverModeName = toLowerCase(serverMode.name()); String serverURLPrefix = RedisClientFactory.getURLPrefix(serverMode); - String urlFix = serverURLPrefix != null ? String.format("\nPlease change the URL prefix to \"%s\".", serverURLPrefix) : null; - throw new SQLException(String.format("The connection mode \"%s\" does not match the server mode \"%s\".%s", - toLowerCase(clientMode.name()), toLowerCase(serverMode.name()), urlFix)); + String messageTail = serverURLPrefix != null + ? String.format("Please change the URL prefix to \"%s\".", serverURLPrefix) + : String.format("Meanwhile, the connection mode \"%s\" is not supported at the moment.", serverModeName); + throw new SQLException(String.format("The connection mode \"%s\" does not match the server mode \"%s\".\n%s", + clientModeName, serverModeName, messageTail)); } }