Skip to content

Errors

Exceptions.

Error

Bases: Exception

Base sigstore exception type. Defines helpers for diagnostics.

diagnostics()

Returns human-friendly error information.

Source code in sigstore/errors.py
27
28
29
30
def diagnostics(self) -> str:
    """Returns human-friendly error information."""

    return str(self)

log_and_exit(logger, raise_error=False)

Prints all relevant error information to stderr and exits.

Source code in sigstore/errors.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def log_and_exit(self, logger: Logger, raise_error: bool = False) -> None:
    """Prints all relevant error information to stderr and exits."""

    remind_verbose = (
        "Raising original exception:"
        if raise_error
        else "For detailed error information, run sigstore with the `--verbose` flag."
    )

    logger.error(f"{self.diagnostics()}\n{remind_verbose}")

    if raise_error:
        # don't want "during handling another exception"
        self.__suppress_context__ = True
        raise self

    sys.exit(1)

NetworkError

Bases: Error

Raised when a connectivity-related issue occurs.

diagnostics()

Returns diagnostics for the error.

Source code in sigstore/errors.py
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def diagnostics(self) -> str:
    """Returns diagnostics for the error."""

    cause_ctx = (
        f"""
    Additional context:

    {self.__cause__}
    """
        if self.__cause__
        else ""
    )

    return (
        """\
    A network issue occurred.

    Check your internet connection and try again.
    """
        + cause_ctx
    )

TUFError(message)

Bases: Error

Raised when a TUF error occurs.

Constructs a TUFError.

Source code in sigstore/errors.py
80
81
82
def __init__(self, message: str):
    """Constructs a `TUFError`."""
    self.message = message

diagnostics()

Returns diagnostics specialized to the wrapped TUF error.

Source code in sigstore/errors.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def diagnostics(self) -> str:
    """Returns diagnostics specialized to the wrapped TUF error."""
    details = TUFError._details.get(
        type(self.__context__),
        "Please report this issue at <https://github.com/sigstore/sigstore-python/issues/new>.",
    )

    return f"""\
    {self.message}.

    {details}
    """

MetadataError

Bases: Error

Raised when TUF metadata does not conform to the expected structure.

diagnostics()

Returns diagnostics for the error.

Source code in sigstore/errors.py
107
108
109
def diagnostics(self) -> str:
    """Returns diagnostics for the error."""
    return f"""{str(self)}."""

RootError

Bases: Error

Raised when TUF cannot establish its root of trust.

diagnostics()

Returns diagnostics for the error.

Source code in sigstore/errors.py
115
116
117
118
119
120
def diagnostics(self) -> str:
    """Returns diagnostics for the error."""
    return """\
    Unable to establish root of trust.

    This error may occur when the resources embedded in this distribution of sigstore-python are out of date."""

VerificationError

Bases: Error

Raised whenever any phase or subcomponent of Sigstore verification fails.