Closed
Description
Description of issue or feature request:
We want to use a shortlist of exceptions that will be thrown from our APIs, so that our users can handle them easily.
On another hand that doesn't stop us from creating other more specific exceptions that derive from those main exceptions.
This allows us to easily test that specific errors were thrown when we expected them.
For example, we are using BadVersionError
and LengthOrHashMismatchError
which derive from RepositoryError
.
Still, there are two use cases that are worth discussing:
- There are multiple places inside
TrustedMetadataSet
where in one API call we are throwing generic and specific exceptions.
That's happening inside each of the functionsupdate*
insideTrustedMetadataSet
we throwRepositoryError
,ReplayedMetadataError
,ExpiredMetadataError
andUnsignedMetadataError
(fromverify_delegate()
) at the same time.
One idea could be to define new specific exceptions (which derive fromRepositoryError
and replace the instances ofRepositoryError
with them.
Read and synchronize with issues:
- Do we need a new MissingInformationError/MissingMetadataError? #1778
- Do we need a new (Metadata)TypeError? #1779
- ngclient: decide what to do with requests (Fetcher impl) errors #1714
- review/document client exceptions #1312
- Inside the
TrustedMetadataSet
update*
function docstrings we only document that we are throwingRepositoryError
without specifying the specific exceptions. If none of them are documented in the Raises section of the method docstrings (they only mention the broad RepositoryError), do we expect anyone to handle them? If we do, we should probably document them?
Inspired by #1725 (comment).
- Inside
_get_session
in moduletuf/ngclient/_internal/request_fetcher.py
we currently throwURLParsingError
:
In my commit e8f26eb inside pr Add new exceptions file for exceptions in the new code #1725 I am replacing it withDownloadError
.
The question is do we want to keep the specific exception -URLParsingError
and make it derive fromDownloadError
?
Does my change in this commit make sense?