Skip to content

Commit

Permalink
Raise RuntimeError when API is incorrectly used
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Aug 19, 2011
1 parent 99569d1 commit 8097994
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/redis.rb
Expand Up @@ -1086,15 +1086,15 @@ def subscribed?
# Stop listening for messages posted to the given channels.
def unsubscribe(*channels)
synchronize do
raise Error, "Can't unsubscribe if not subscribed." unless subscribed?
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
@client.unsubscribe(*channels)
end
end

# Stop listening for messages posted to channels matching the given patterns.
def punsubscribe(*channels)
synchronize do
raise Error, "Can't unsubscribe if not subscribed." unless subscribed?
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
@client.punsubscribe(*channels)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/redis/distributed.rb
Expand Up @@ -599,7 +599,7 @@ def subscribed?

# Stop listening for messages posted to the given channels.
def unsubscribe(*channels)
raise Error, "Can't unsubscribe if not subscribed." unless subscribed?
raise RuntimeError, "Can't unsubscribe if not subscribed." unless subscribed?
@subscribed_node.unsubscribe(*channels)
end

Expand Down
4 changes: 2 additions & 2 deletions test/publish_subscribe_test.rb
Expand Up @@ -128,11 +128,11 @@
end

test "UNSUBSCRIBE without a SUBSCRIBE" do |r|
assert_raise Redis::Error do
assert_raise RuntimeError do
r.unsubscribe
end

assert_raise Redis::Error do
assert_raise RuntimeError do
r.punsubscribe
end
end
Expand Down

0 comments on commit 8097994

Please sign in to comment.