<filename>src/eduid_userdb/exceptions.py
"""
Exceptions thrown by the eduid_userdb database lookup functions.
"""
from typing import Any


class EduIDDBError(Exception):
    """
    eduID userdb Exception class.

    :param reason: Reason for exception (typically a string)
    :type reason: object
    """

    def __init__(self, reason: Any):
        Exception.__init__(self)
        self.reason = reason

    def __str__(self):
        return '<{cl} instance at {addr}: {reason!r}>'.format(
            cl=self.__class__.__name__, addr=hex(id(self)), reason=self.reason,
        )


class ConnectionError(EduIDDBError):
    """
    Error connecting to the database.
    """

    pass


class MongoConnectionError(ConnectionError):
    """
    Error connecting to MongoDB.
    """

    pass


class DocumentDoesNotExist(EduIDDBError):
    pass


class UserDoesNotExist(DocumentDoesNotExist):
    """
    Requested user could not be found in the database.
    """

    pass


class MultipleDocumentsReturned(EduIDDBError):
    pass


class MultipleUsersReturned(MultipleDocumentsReturned):
    """
    More than one user in the database matched the given search criteria.
    """

    pass


class EduIDUserDBError(EduIDDBError):
    """
    eduID userdb Exception class.
    """

    pass


class UserHasUnknownData(EduIDUserDBError):
    """
    One or more elements of the user could not be interpreted.
    """

    pass


class UserDBValueError(EduIDUserDBError):
    """
    Error regarding APIAuthUser instances.
    """

    pass


class UserMissingData(EduIDUserDBError):
    """
    There is missing data for a User
    """

    pass


class DocumentOutOfSync(EduIDDBError):
    """
    The document has been modified since it was read from the db.
    """

    pass


class LockedIdentityViolation(EduIDUserDBError):
    """
    The user is trying to verify an identity that differs from the current locked identity.
    """

    pass


class UserOutOfSync(DocumentOutOfSync):
    """
    The user has been modified since it was read from the db.
    """

    pass


class UserIsRevoked(EduIDUserDBError):
    """
    The user has been permanently deleted from eduID.

    The only things remaining are the _id and eppn, as placeholders to make sure
    they are never ever re-used (Kantara requirement).
    """

    pass


class UserHasNotCompletedSignup(EduIDUserDBError):
    """
    The user has not completed the Signup process.

    Signup has created lots of users in the database with only eppn, mail and mailAliases.
    """

    pass


class ActionDBError(EduIDUserDBError):
    """
    There was an actions-database related error
    """

    pass


class BadEvent(EduIDUserDBError):
    """
    General error in Event processing.
    """

    pass


class EventHasUnknownData(BadEvent):
    """
    One or more elements of the event could not be interpreted.
    """

    pass

<filename>src/eduid_userdb/exceptions.py
"""
Exceptions thrown by the eduid_userdb database lookup functions.
"""
from typing import Any


class EduIDDBError(Exception):
    """
    eduID userdb Exception class.

    :param reason: Reason for exception (typically a string)
    :type reason: object
    """

    def __init__(self, reason: Any):
        Exception.__init__(self)
        self.reason = reason

    def __str__(self):
        return '<{cl} instance at {addr}: {reason!r}>'.format(
            cl=self.__class__.__name__, addr=hex(id(self)), reason=self.reason,
        )


class ConnectionError(EduIDDBError):
    """
    Error connecting to the database.
    """

    pass


class MongoConnectionError(ConnectionError):
    """
    Error connecting to MongoDB.
    """

    pass


class DocumentDoesNotExist(EduIDDBError):
    pass


class UserDoesNotExist(DocumentDoesNotExist):
    """
    Requested user could not be found in the database.
    """

    pass


class MultipleDocumentsReturned(EduIDDBError):
    pass


class MultipleUsersReturned(MultipleDocumentsReturned):
    """
    More than one user in the database matched the given search criteria.
    """

    pass


class EduIDUserDBError(EduIDDBError):
    """
    eduID userdb Exception class.
    """

    pass


class UserHasUnknownData(EduIDUserDBError):
    """
    One or more elements of the user could not be interpreted.
    """

    pass


class UserDBValueError(EduIDUserDBError):
    """
    Error regarding APIAuthUser instances.
    """

    pass


class UserMissingData(EduIDUserDBError):
    """
    There is missing data for a User
    """

    pass


class DocumentOutOfSync(EduIDDBError):
    """
    The document has been modified since it was read from the db.
    """

    pass


class LockedIdentityViolation(EduIDUserDBError):
    """
    The user is trying to verify an identity that differs from the current locked identity.
    """

    pass


class UserOutOfSync(DocumentOutOfSync):
    """
    The user has been modified since it was read from the db.
    """

    pass


class UserIsRevoked(EduIDUserDBError):
    """
    The user has been permanently deleted from eduID.

    The only things remaining are the _id and eppn, as placeholders to make sure
    they are never ever re-used (Kantara requirement).
    """

    pass


class UserHasNotCompletedSignup(EduIDUserDBError):
    """
    The user has not completed the Signup process.

    Signup has created lots of users in the database with only eppn, mail and mailAliases.
    """

    pass


class ActionDBError(EduIDUserDBError):
    """
    There was an actions-database related error
    """

    pass


class BadEvent(EduIDUserDBError):
    """
    General error in Event processing.
    """

    pass


class EventHasUnknownData(BadEvent):
    """
    One or more elements of the event could not be interpreted.
    """

    pass

Exceptions thrown by the eduid_userdb database lookup functions. eduID userdb Exception class.      :param reason: Reason for exception (typically a string)     :type reason: object Error connecting to the database. Error connecting to MongoDB. Requested user could not be found in the database. More than one user in the database matched the given search criteria. eduID userdb Exception class. One or more elements of the user could not be interpreted. Error regarding APIAuthUser instances. There is missing data for a User The document has been modified since it was read from the db. The user is trying to verify an identity that differs from the current locked identity. The user has been modified since it was read from the db. The user has been permanently deleted from eduID.      The only things remaining are the _id and eppn, as placeholders to make sure     they are never ever re-used (Kantara requirement). The user has not completed the Signup process.      Signup has created lots of users in the database with only eppn, mail and mailAliases. There was an actions-database related error General error in Event processing. One or more elements of the event could not be interpreted.