Skip to content

Exceptions

secret_type.exceptions

This module contains exceptions that are used by the rest of the library.

SecretException

Bases: Exception

The base exception for this library.

All other exceptions are subclasses of this one.

Source code in secret_type/exceptions.py
 9
10
11
12
13
14
15
class SecretException(Exception):
    """The base exception for this library.

    All other exceptions are subclasses of this one."""

    def __init__(self, message: str = "Secrets cannot be examined") -> None:
        super().__init__(message)

SecretFloatException

Bases: SecretException

Raised when an unsupported operation is attempted on a Secret[NumberLike].

Source code in secret_type/exceptions.py
18
19
20
21
22
23
24
25
class SecretFloatException(SecretException):
    """Raised when an unsupported operation is attempted on a [`Secret[NumberLike]`][secret_type.typing.types.NumberLike]."""

    def __init__(
        self,
        message: str = "Secrets cannot be used as non-integral numbers",
    ) -> None:
        super().__init__(message)

SecretKeyException

Bases: SecretException

Raised when a Secret is used as a key or index.

Source code in secret_type/exceptions.py
28
29
30
31
32
33
34
35
class SecretKeyException(SecretException):
    """Raised when a [`Secret`][secret_type.Secret] is used as a key or index."""

    def __init__(
        self,
        message: str = "Secrets cannot be used as keys",
    ) -> None:
        super().__init__(message)

SecretBoolException

Bases: SecretException

Raised when a Secret[bool] is used for control flow.

Source code in secret_type/exceptions.py
38
39
40
41
42
43
44
45
class SecretBoolException(SecretException):
    """Raised when a [`Secret[bool]`][secret_type.Secret] is used for control flow."""

    def __init__(
        self,
        message: str = "bools derived from Secrets cannot be used for control flow",
    ) -> None:
        super().__init__(message)