themes kitten: Nicer error message when no internet connection is present

Fixes #5877
This commit is contained in:
Kovid Goyal 2023-01-11 09:00:58 +05:30
parent 15524ee0fb
commit d4e34a4c31
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -233,8 +233,11 @@ class ThemesHandler(Handler):
self.redraw_after_category_change() self.redraw_after_category_change()
def fetch() -> None: def fetch() -> None:
from urllib.error import URLError
try: try:
themes: Union[Themes, str] = load_themes(self.cli_opts.cache_age) themes: Union[Themes, str] = load_themes(self.cli_opts.cache_age)
except URLError as e:
themes = f'Could not download themes, check your internet connection. Error: {e}'
except Exception: except Exception:
themes = format_traceback('Failed to download themes') themes = format_traceback('Failed to download themes')
self.asyncio_loop.call_soon_threadsafe(fetching_done, themes) self.asyncio_loop.call_soon_threadsafe(fetching_done, themes)