Skip to content

Commit

Permalink
chore: sneaky throw AblyException
Browse files Browse the repository at this point in the history
  • Loading branch information
ttypic committed Nov 23, 2023
1 parent 6dd4461 commit 002613e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/src/main/java/io/ably/lib/realtime/ChannelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)));
}

/**
Expand Down
7 changes: 7 additions & 0 deletions lib/src/main/java/io/ably/lib/util/Exceptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.ably.lib.util;

public class Exceptions {
public static <E extends Throwable> void sneakyThrow(Throwable e) throws E {
throw (E) e;
}
}

0 comments on commit 002613e

Please sign in to comment.