smartgic/skill-sonos-controller

Handle error when no results are found

goldyfruit opened this issue · 0 comments

Utterance play a jazz playlist from plex on office returns an error because there is no jazz playlist available on Plex.
The skill should handle this error and return a dialog message.

Traceback (most recent call last):
  File "/home/mycroft/core/mycroft/skills/mycroft_skill/event_container.py", line 73, in wrapper
    handler(message)
  File "/opt/mycroft/skills/mycroft-sonos-controller-skill.smartgic/__init__.py", line 132, in _handle_playlist
    search(self, service, speaker, 'playlists', playlist=playlist)
  File "/opt/mycroft/skills/mycroft-sonos-controller-skill.smartgic/search.py", line 50, in search
    search_type(self, data)
  File "/opt/mycroft/skills/mycroft-sonos-controller-skill.smartgic/search.py", line 64, in search_type
    search_playlist(self, data)
  File "/opt/mycroft/skills/mycroft-sonos-controller-skill.smartgic/search.py", line 104, in search_playlist
    picked = choice(playlists)
  File "/usr/lib/python3.7/random.py", line 261, in choice
    raise IndexError('Cannot choose from an empty sequence') from None
IndexError: Cannot choose from an empty sequence