Skip to content

Commit 47aca93

Browse files
committed
Improve error messages on failures
I started injecting failures to Kodi and this makes it handle them better.
1 parent 4e17423 commit 47aca93

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

resources/language/resource.language.en_gb/strings.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ msgid "No connection"
967967
msgstr ""
968968

969969
msgctxt "#30969"
970-
msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details."
970+
msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details.\n[COLOR=yellow]{reason}[/COLOR]"
971971
msgstr ""
972972

973973
msgctxt "#30970"

resources/language/resource.language.nl_nl/strings.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,8 @@ msgid "No connection"
967967
msgstr "Geen verbinding"
968968

969969
msgctxt "#30969"
970-
msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details."
971-
msgstr "Er is een probleem met het verbinden met internet. Dit kan liggen aan Kodi, aan jouw netwerk, aan jouw ISP of aan VRT NU. Bekijk de Kodi-log voor meer details."
970+
msgid "There is a problem connecting to the Internet. This could be related to Kodi, your network, your ISP or VRT NU. Check out the Kodi log for more details.\n[COLOR=yellow]{reason}[/COLOR]"
971+
msgstr "Er is een probleem met het verbinden met internet. Dit kan liggen aan Kodi, aan jouw netwerk, aan jouw ISP of aan VRT NU. Bekijk de Kodi-log voor meer details.\n[COLOR=yellow]{reason}[/COLOR]"
972972

973973
msgctxt "#30970"
974974
msgid "VRT NU authentication failed"

resources/lib/apihelper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,10 @@ def get_episodes(self, program=None, season=None, episodes=None, category=None,
596596
else:
597597
search_json = get_url_json(url=search_url, fail={})
598598

599+
# Fail more gracefully on network errors
600+
if not search_json:
601+
return []
602+
599603
# Check for multiple seasons
600604
seasons = []
601605
if 'facets[seasonTitle]' not in unquote(search_url):

resources/lib/kodiutils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,22 +1120,24 @@ def open_url(url, data=None, headers=None, method=None, cookiejar=None, follow_r
11201120
log_error('HTTP Error {code}: {reason}', code=code, reason=reason)
11211121
return None
11221122
except URLError as exc:
1123-
ok_dialog(heading=localize(30968), message=localize(30969))
1124-
log_error('URLError: {error}\nurl: {url}', error=exc.reason, url=url)
1123+
ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason))
1124+
log_error('URLError: {reason}\nurl: {url}', reason=exc.reason, url=url)
11251125
return None
11261126
except SSLError as exc:
11271127
# TODO: Include the error message in the notification window
1128-
ok_dialog(heading=localize(30968), message=localize(30969))
11291128
if hasattr(exc, 'reason'): # Python 2.7.9+, but still failed on Python 2.7.16
1130-
log_error('SSLError: {error} ({library})\nurl: {url}', error=exc.reason, library=exc.library, url=url)
1129+
ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason))
1130+
log_error('SSLError: {reason} ({library})\nurl: {url}', reason=exc.reason, library=exc.library, url=url)
11311131
elif isinstance(exc, list):
1132-
log_error('SSLError: {error} ({errno})\nurl: {url}', errno=exc[0], error=exc[1], url=url)
1132+
ok_dialog(heading=localize(30968), message=localize(30969, reason='{e[1]} ({e[0]})'.format(e=exc)))
1133+
log_error('SSLError: {reason} ({errno})\nurl: {url}', errno=exc[0], reason=exc[1], url=url)
11331134
else:
1134-
log_error('SSLError: {error}\nurl: {url}', error=str(exc), url=url)
1135+
ok_dialog(heading=localize(30968), message=localize(30969, reason=str(exc)))
1136+
log_error('SSLError: {reason}\nurl: {url}', reason=str(exc), url=url)
11351137
return None
11361138
except timeout as exc:
1137-
ok_dialog(heading=localize(30968), message=localize(30969))
1138-
log_error('Timeout: {error}\nurl: {url}', error=exc.reason, url=url)
1139+
ok_dialog(heading=localize(30968), message=localize(30969, reason=exc.reason))
1140+
log_error('Timeout: {reason}\nurl: {url}', reason=exc.reason, url=url)
11391141
return None
11401142

11411143

0 commit comments

Comments
 (0)