updater: Minor improvements to error handling

In RequestsFetcher it makes sense to raise "from e" but in
updater the error we raise is not related to the original
error: use "from None".

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
This commit is contained in:
Jussi Kukkonen 2024-03-08 15:00:42 +02:00
parent 27cc46f61d
commit 289950a17c
2 changed files with 2 additions and 2 deletions

View file

@ -94,7 +94,7 @@ def _fetch(self, url: str) -> Iterator[bytes]:
except requests.HTTPError as e:
response.close()
status = e.response.status_code
raise exceptions.DownloadHTTPError(str(e), status)
raise exceptions.DownloadHTTPError(str(e), status) from e
return self._chunks(response)

View file

@ -397,7 +397,7 @@ def _load_targets(self, role: str, parent_role: str) -> Targets:
if metainfo is None:
raise exceptions.RepositoryError(
f"Role {role} was delegated but is not part of snapshot"
)
) from None
length = metainfo.length or self.config.targets_max_length
version = None