Skip to content

Commit 73d0aab

Browse files
committed
bot: raise ValueError instead of RuntimeError
1 parent a12b8e6 commit 73d0aab

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

sopel/bot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def has_channel_privilege(self, channel, privilege):
205205
206206
:param str channel: a channel the bot is in
207207
:param int privilege: privilege level to check
208-
:raise RuntimeError: when the channel is unknown
208+
:raise ValueError: when the channel is unknown
209209
210210
This method checks the bot's privilege level in a channel, i.e. if it
211211
has this level or higher privileges::
@@ -216,9 +216,10 @@ def has_channel_privilege(self, channel, privilege):
216216
217217
The ``channel`` argument can be either a :class:`str` or a
218218
:class:`sopel.tools.Identifier`, as long as Sopel joined said channel.
219+
If the channel is unknown, a :exc:`ValueError` will be raised.
219220
"""
220221
if channel not in self.channels:
221-
raise RuntimeError('Unknown channel %s' % channel)
222+
raise ValueError('Unknown channel %s' % channel)
222223

223224
return self.channels[channel].has_privilege(self.nick, privilege)
224225

test/test_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ def test_has_channel_privilege_no_privilege(ircfactory, botfactory, tmpconfig):
772772
name = Identifier('#adminchannel')
773773

774774
# unknown channel
775-
with pytest.raises(RuntimeError):
775+
with pytest.raises(ValueError):
776776
sopel.has_channel_privilege('#adminchannel', plugin.VOICE)
777777

778778
# join channel
@@ -793,7 +793,7 @@ def test_has_channel_privilege_no_privilege(ircfactory, botfactory, tmpconfig):
793793
assert not sopel.has_channel_privilege('#adminchannel', plugin.OPER)
794794

795795
# unknown channel
796-
with pytest.raises(RuntimeError):
796+
with pytest.raises(ValueError):
797797
sopel.has_channel_privilege('#anotherchannel', plugin.VOICE)
798798

799799

0 commit comments

Comments
 (0)