change RuntimeException to IllegalStateException

This commit is contained in:
mohammed jasem alaajel 2022-07-23 08:21:36 +04:00
parent 9ceccb6dd2
commit 2b2ae88587
1 changed files with 19 additions and 15 deletions

View File

@ -362,12 +362,13 @@ public class RedisBungeeAPI {
* *
* @return {@link Jedis} * @return {@link Jedis}
* @since 0.7.0 * @since 0.7.0
* @throws IllegalStateException if the #getMode is not equal to {@link RedisBungeeMode#SINGLE}
*/ */
public Jedis requestJedis() { public Jedis requestJedis() {
if (getMode() == RedisBungeeMode.SINGLE) { if (getMode() == RedisBungeeMode.SINGLE) {
return ((JedisSummoner) this.plugin.getSummoner()).obtainResource(); return ((JedisSummoner) this.plugin.getSummoner()).obtainResource();
} else { } else {
throw new RuntimeException("RedisBungee is on Cluster MODE!"); throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
} }
} }
@ -376,12 +377,28 @@ public class RedisBungeeAPI {
* *
* @return {@link JedisPool} * @return {@link JedisPool}
* @since 0.6.5 * @since 0.6.5
* @throws IllegalStateException if the #getMode is not equal to {@link RedisBungeeMode#SINGLE}
*/ */
public JedisPool getJedisPool() { public JedisPool getJedisPool() {
if (getMode() == RedisBungeeMode.SINGLE) { if (getMode() == RedisBungeeMode.SINGLE) {
return ((JedisSummoner) this.plugin.getSummoner()).getJedisPool(); return ((JedisSummoner) this.plugin.getSummoner()).getJedisPool();
} else { } else {
throw new RuntimeException("RedisBungee is on Cluster MODE!"); throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
}
}
/**
* This gives you instance of Jedis Cluster
*
* @return {@link redis.clients.jedis.JedisCluster}
* @since 0.8.0
* @throws IllegalStateException if the #getMode is not equal to {@link RedisBungeeMode#CLUSTER}
*/
public Jedis requestClusterJedis() {
if (getMode() == RedisBungeeMode.CLUSTER) {
return ((JedisSummoner) this.plugin.getSummoner()).obtainResource();
} else {
throw new IllegalStateException("Mode is not " + RedisBungeeMode.CLUSTER);
} }
} }
@ -395,19 +412,6 @@ public class RedisBungeeAPI {
return this.plugin.getSummoner(); return this.plugin.getSummoner();
} }
/**
* This gives you instance of Jedis Cluster
*
* @return {@link redis.clients.jedis.JedisCluster}
* @since 0.8.0
*/
public Jedis requestClusterJedis() {
if (getMode() == RedisBungeeMode.CLUSTER) {
return ((JedisSummoner) this.plugin.getSummoner()).obtainResource();
} else {
throw new RuntimeException("RedisBungee is on single MODE!");
}
}
/** /**
* shows what mode is RedisBungee is on * shows what mode is RedisBungee is on