Skip to content

Commit a85eb68

Browse files
committed
fix: only raise URLError or HTTPError when there are no results at all
1 parent 93f62f2 commit a85eb68

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tldr.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def get_page_for_every_platform(
281281
return result
282282
# Know here that we don't have the info in cache
283283
result = list()
284+
error = None
284285
for platform in platforms:
285286
for language in languages:
286287
if platform is None:
@@ -300,13 +301,22 @@ def get_page_for_every_platform(
300301
break
301302
except HTTPError as err:
302303
if err.code != 404:
303-
raise
304-
except URLError:
304+
# Store error for later, only raise if we find no results at all
305+
error = err
306+
except URLError as err:
305307
if not PAGES_SOURCE_LOCATION.startswith('file://'):
306-
raise
308+
# Store error for later, only raise if we find no results at all
309+
error = err
310+
307311
if result: # Return if smth was found
308312
return result
309313

314+
# Reraise the error if we couldn't get the pages for any platform
315+
if error is not None:
316+
# Note that only the most recent error will be stored and raised
317+
raise error
318+
319+
# Otherwise, we got no results nor errors, implies the documentation doesn't exist
310320
return False
311321

312322

0 commit comments

Comments
 (0)