Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/tuf/api/exceptions.py: 81%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright New York University and the TUF contributors
2# SPDX-License-Identifier: MIT OR Apache-2.0
4"""
5Define TUF exceptions used inside the new modern implementation.
6The names chosen for TUF Exception classes should end in 'Error' except where
7there is a good reason not to, and provide that reason in those cases.
8"""
11#### Repository errors ####
13from securesystemslib.exceptions import StorageError # noqa: F401
16class RepositoryError(Exception):
17 """An error with a repository's state, such as a missing file.
19 It covers all exceptions that come from the repository side when
20 looking from the perspective of users of metadata API or ngclient.
21 """
24class UnsignedMetadataError(RepositoryError):
25 """An error about metadata object with insufficient threshold of
26 signatures.
27 """
30class BadVersionNumberError(RepositoryError):
31 """An error for metadata that contains an invalid version number."""
34class EqualVersionNumberError(BadVersionNumberError):
35 """An error for metadata containing a previously verified version number."""
38class ExpiredMetadataError(RepositoryError):
39 """Indicate that a TUF Metadata file has expired."""
42class LengthOrHashMismatchError(RepositoryError):
43 """An error while checking the length and hash values of an object."""
46#### Download Errors ####
49class DownloadError(Exception):
50 """An error occurred while attempting to download a file."""
53class DownloadLengthMismatchError(DownloadError):
54 """Indicate that a mismatch of lengths was seen while downloading a file."""
57class SlowRetrievalError(DownloadError):
58 """Indicate that downloading a file took an unreasonably long time."""
61class DownloadHTTPError(DownloadError):
62 """
63 Returned by FetcherInterface implementations for HTTP errors.
65 Args:
66 message: The HTTP error message
67 status_code: The HTTP status code
68 """
70 def __init__(self, message: str, status_code: int):
71 super().__init__(message)
72 self.status_code = status_code