diff --git a/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java b/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java index 4163876c3..a9c170509 100644 --- a/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java +++ b/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java @@ -33,10 +33,7 @@ import io.ably.lib.types.ProtocolMessage; import io.ably.lib.types.ProtocolMessage.Action; import io.ably.lib.types.ProtocolMessage.Flag; -import io.ably.lib.util.CollectionUtils; -import io.ably.lib.util.EventEmitter; -import io.ably.lib.util.Log; -import io.ably.lib.util.ReconnectionStrategy; +import io.ably.lib.util.*; /** * Enables messages to be published and subscribed to. @@ -507,7 +504,7 @@ public void run() { } private void checkChannelIsNotReleased() { - if (released) throw new IllegalStateException("Can't perform any operation on released channel"); + if (released) Exceptions.sneakyThrow(AblyException.fromErrorInfo(new ErrorInfo("Unable to perform any operation on released channel", 90001))); } /** diff --git a/lib/src/main/java/io/ably/lib/util/Exceptions.java b/lib/src/main/java/io/ably/lib/util/Exceptions.java new file mode 100644 index 000000000..fc69b6f23 --- /dev/null +++ b/lib/src/main/java/io/ably/lib/util/Exceptions.java @@ -0,0 +1,7 @@ +package io.ably.lib.util; + +public class Exceptions { + public static void sneakyThrow(Throwable e) throws E { + throw (E) e; + } +}