Skip to content

Commit 7bb916f

Browse files
committed
Document DownloadError for RequestsFetcher.fetch()
We should document that "DownloadError" is thrown inside RequestsFetcher.fetch(). Signed-off-by: Martin Vrachev <[email protected]>
1 parent 8327ea1 commit 7bb916f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def fetch(self, url: str) -> Iterator[bytes]:
6161
exceptions.SlowRetrievalError: A timeout occurs while receiving
6262
data.
6363
exceptions.FetcherHTTPError: An HTTP error code is received.
64+
exceptions.DownloadError: When there is a problem parsing the url.
6465
6566
Returns:
6667
A bytes iterator
@@ -126,13 +127,16 @@ def _chunks(self, response: "requests.Response") -> Iterator[bytes]:
126127
def _get_session(self, url: str) -> requests.Session:
127128
"""Returns a different customized requests.Session per schema+hostname
128129
combination.
130+
131+
Raises:
132+
exceptions.DownloadError: When there is a problem parsing the url.
129133
"""
130134
# Use a different requests.Session per schema+hostname combination, to
131135
# reuse connections while minimizing subtle security issues.
132136
parsed_url = parse.urlparse(url)
133137

134138
if not parsed_url.scheme or not parsed_url.hostname:
135-
raise exceptions.DownloadError("Failed to parse URL")
139+
raise exceptions.DownloadError("Failed to parse URL {url}")
136140

137141
session_index = parsed_url.scheme + "+" + parsed_url.hostname
138142
session = self._sessions.get(session_index)

0 commit comments

Comments
 (0)