Skip to content

Commit

Permalink
Tidy up some exception catching
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Apr 2, 2024
1 parent d19c542 commit 5782e7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def addon_enabled(self, addon_id):
'properties': ['enabled']})
try:
return response['result']['addon']['enabled'] is True
except KeyError:
except (KeyError, TypeError):
error = response.get('error', {})
self.log_error('XbmcContext.addon_enabled error - |{0}: {1}|'
.format(error.get('code', 'unknown'),
Expand All @@ -547,7 +547,7 @@ def set_addon_enabled(self, addon_id, enabled=True):
'enabled': enabled})
try:
return response['result'] == 'OK'
except KeyError:
except (KeyError, TypeError):
error = response.get('error', {})
self.log_error('XbmcContext.set_addon_enabled error - |{0}: {1}|'
.format(error.get('code', 'unknown'),
Expand Down
10 changes: 8 additions & 2 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,16 @@ def merge_dicts(item1, item2, templates=None, _=Ellipsis):
return new or _


def get_kodi_setting_value(setting):
def get_kodi_setting_value(setting, process=None):
response = jsonrpc(method='Settings.GetSettingValue',
params={'setting': setting})
return response.get('result', {}).get('value')
try:
value = response['result']['value']
if process:
return process(value)
except (KeyError, TypeError, ValueError):
return None
return value


def get_kodi_setting_bool(setting):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, version=None, releasename=None, appname=None):
self._version = (version_installed.get('major', 1),
version_installed.get('minor', 0))
self._appname = response['result']['name']
except:
except (KeyError, TypeError):
self._version = (1, 0) # Frodo
self._appname = 'Unknown Application'

Expand Down

0 comments on commit 5782e7b

Please sign in to comment.