Skip to content

Commit 62e2c9c

Browse files
committed
Remove URLParsingError
URLParsingError is a specific download error that and its not clear what benefit it provides when it's used only once in the new code and the message says everything you need to know about the exception. Signed-off-by: Martin Vrachev <[email protected]>
1 parent 525a0eb commit 62e2c9c

File tree

3 files changed

+2
-9
lines changed

3 files changed

+2
-9
lines changed

tests/test_fetcher_ng.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_fetch_in_chunks(self) -> None:
110110

111111
# Incorrect URL parsing
112112
def test_url_parsing(self) -> None:
113-
with self.assertRaises(exceptions.URLParsingError):
113+
with self.assertRaises(exceptions.DownloadError):
114114
self.fetcher.fetch(self.random_string())
115115

116116
# File not found error

tuf/api/exceptions.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ class LengthOrHashMismatchError(Exception):
1919
"""An error while checking the length and hash values of an object."""
2020

2121

22-
class URLParsingError(Exception):
23-
"""If we are unable to parse a URL -- for example, if a hostname element
24-
cannot be isoalted."""
25-
26-
2722
#### Repository errors ####
2823

2924

tuf/ngclient/_internal/requests_fetcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ def _get_session(self, url: str) -> requests.Session:
132132
parsed_url = parse.urlparse(url)
133133

134134
if not parsed_url.scheme or not parsed_url.hostname:
135-
raise exceptions.URLParsingError(
136-
"Could not get scheme and hostname from URL: " + url
137-
)
135+
raise exceptions.DownloadError("Failed to parse URL")
138136

139137
session_index = parsed_url.scheme + "+" + parsed_url.hostname
140138
session = self._sessions.get(session_index)

0 commit comments

Comments
 (0)