From a85eb687acc08ee2b6a9016b9bc1b2bda9b48e30 Mon Sep 17 00:00:00 2001 From: kyluca Date: Thu, 9 Oct 2025 10:49:57 +1000 Subject: [PATCH] fix: only raise URLError or HTTPError when there are no results at all --- tldr.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tldr.py b/tldr.py index fb81560..8debf1f 100755 --- a/tldr.py +++ b/tldr.py @@ -281,6 +281,7 @@ def get_page_for_every_platform( return result # Know here that we don't have the info in cache result = list() + error = None for platform in platforms: for language in languages: if platform is None: @@ -300,13 +301,22 @@ def get_page_for_every_platform( break except HTTPError as err: if err.code != 404: - raise - except URLError: + # Store error for later, only raise if we find no results at all + error = err + except URLError as err: if not PAGES_SOURCE_LOCATION.startswith('file://'): - raise + # Store error for later, only raise if we find no results at all + error = err + if result: # Return if smth was found return result + # Reraise the error if we couldn't get the pages for any platform + if error is not None: + # Note that only the most recent error will be stored and raised + raise error + + # Otherwise, we got no results nor errors, implies the documentation doesn't exist return False