Skip to content

Commit f3272be

Browse files
committed
Fixed some errors related to menus. (#487)
1 parent f129713 commit f3272be

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

addons/source-python/packages/source-python/menus/queue.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def _validate_selection(command, index, valid_choices):
219219
"""
220220
try:
221221
choice = int(command[1])
222-
except ValueError:
222+
except (ValueError, IndexError):
223223
# Catch errors caused by e.g. "menuselect a"
224224
return (None, None)
225225

addons/source-python/packages/source-python/menus/radio.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,12 @@ def _select(self, player_index, choice_index):
108108
if choice_index == BUTTON_CLOSE:
109109
return self._select_close(player_index)
110110

111-
return super()._select(
112-
player_index,
113-
self._player_pages[player_index].options[choice_index])
111+
try:
112+
option = self._player_pages[player_index].options[choice_index]
113+
except KeyError:
114+
return
115+
116+
return super()._select(player_index, option)
114117

115118
def _send(self, player_index):
116119
"""Build and sends the menu to the given player via ShowMenu.

0 commit comments

Comments
 (0)