Skip to content

Exceptions

Module: s2auth.common.exceptions

ErrorType = Union[PairingErrorType, ConnectionErrorType] module-attribute

PairingErrorType

Bases: str, Enum

Source code in src/s2auth/common/model/s2_connect_pairing.py
class ErrorMessage(str, Enum):
    InvalidCombinationOfRoles = "InvalidCombinationOfRoles"
    IncompatibleS2MessageVersions = "IncompatibleS2MessageVersions"
    IncompatibleHmacHashingAlgorithms = "IncompatibleHmacHashingAlgorithms"
    IncompatibleCommunicationProtocols = "IncompatibleCommunicationProtocols"
    NodeNotFound = "NodeNotFound"
    NoNodeIdProvided = "NoNodeIdProvided"
    NoValidPairingTokenOnPairingServer = "NoValidPairingTokenOnPairingServer"
    ParsingError = "ParsingError"
    Other = "Other"

ConnectionErrorType

Bases: str, Enum

Source code in src/s2auth/common/model/s2_connect_session_init.py
class ErrorMessage(str, Enum):
    IncompatibleS2MessageVersions = "IncompatibleS2MessageVersions"
    IncompatibleCommunicationProtocols = "IncompatibleCommunicationProtocols"
    NoLongerPaired = "NoLongerPaired"
    ParsingError = "ParsingError"
    Other = "Other"

S2ConnectError

Bases: Exception, ABC

Base exception for S2 Connect errors

Subclasses must define the error_type class attribute.

Source code in src/s2auth/common/exceptions.py
class S2ConnectError(Exception, ABC):
    """Base exception for S2 Connect errors

    Subclasses must define the error_type class attribute.
    """

    error_type: ClassVar[ErrorType]

    def __init__(self, message: str):
        super().__init__(message)
        self.message = message

S2PairingError

Bases: S2ConnectError

Base exception for S2 pairing errors

Source code in src/s2auth/common/exceptions.py
class S2PairingError(S2ConnectError):
    """Base exception for S2 pairing errors"""
    pass

S2ConnectErrorWithDetails

Bases: S2ConnectError, ABC

Base exception for S2 Connect errors

Subclasses must define the error_type class attribute.

Source code in src/s2auth/common/exceptions.py
class S2ConnectErrorWithDetails(S2ConnectError, ABC):
    """Base exception for S2 Connect errors

    Subclasses must define the error_type class attribute.
    """

    additional_info: str

    def __init__(self, message: str, additional_info: str):
        super().__init__(message)
        self.additional_info = additional_info

IncompatibleHmacHashingAlgorithms

Bases: S2ConnectError

Raised when no common HMAC hashing algorithm is found

Source code in src/s2auth/common/exceptions.py
class IncompatibleHmacHashingAlgorithms(S2ConnectError):
    """Raised when no common HMAC hashing algorithm is found"""

    error_type = PairingErrorType.IncompatibleHmacHashingAlgorithms

VerificationError

Bases: S2ConnectError

Digest verification failed

Source code in src/s2auth/common/exceptions.py
class VerificationError(S2ConnectError):
    """Digest verification failed"""

    error_type = PairingErrorType.Other  # TODO should be something else.

AccessError

Bases: S2ConnectError

Permission is denied to the client. This generally results in an HTTP 401 error.

Source code in src/s2auth/common/exceptions.py
class AccessError(S2ConnectError):
    """Permission is denied to the client. This generally results in an HTTP 401 error."""

    error_type = PairingErrorType.Other  # TODO should be something else.

PairingNotCompleteError

Bases: S2ConnectError

Pairing was not completed successfully before initiating a connection.

Source code in src/s2auth/common/exceptions.py
class PairingNotCompleteError(S2ConnectError):
    """Pairing was not completed successfully before initiating a connection."""

    error_type = ConnectionErrorType.NoLongerPaired  # TODO should be something else.

InvalidAccessTokenError

Bases: AccessError

Invalid AccessToken when authenticating a new s2 connection.

Source code in src/s2auth/common/exceptions.py
class InvalidAccessTokenError(AccessError):
    """Invalid AccessToken when authenticating a new s2 connection."""

    error_type = ConnectionErrorType.Other  # TODO should be something else

InvalidServerError

Bases: AccessError

Unknown serverNodeId was specified for this server.

Source code in src/s2auth/common/exceptions.py
class InvalidServerError(AccessError):
    """Unknown serverNodeId was specified for this server."""

    error_type = ConnectionErrorType.Other  # TODO should be something else

NoCompatibleS2ConnectVersionError

Bases: S2ConnectErrorWithDetails

No compatible S2Connect versions are available between the client and server.

Source code in src/s2auth/common/exceptions.py
class NoCompatibleS2ConnectVersionError(S2ConnectErrorWithDetails):
    """No compatible S2Connect versions are available between the client and server."""

    error_type = ConnectionErrorType.Other  # TODO should be something else

NoCompatibleS2VersionError

Bases: S2ConnectErrorWithDetails

No compatible S2 versions are available between the client and server.

Source code in src/s2auth/common/exceptions.py
class NoCompatibleS2VersionError(S2ConnectErrorWithDetails):
    """No compatible S2 versions are available between the client and server."""

    error_type = ConnectionErrorType.IncompatibleS2MessageVersions

NoCompatibleCommunitcationProtocol

Bases: S2ConnectErrorWithDetails

No compatible communication protocols are available between the client and server.

Source code in src/s2auth/common/exceptions.py
class NoCompatibleCommunitcationProtocol(S2ConnectErrorWithDetails):
    """No compatible communication protocols are available between the client and server."""

    error_type = ConnectionErrorType.IncompatibleCommunicationProtocols