class InvalidAppClassException(Exception):
    def __init__(self, app) -> None:
        super().__init__('{app} is invalid app. SDK supports Fast API and Flask'.format(app=app))


class InvalidAppDescriptorException(Exception):
    def __init__(self, message) -> None:
        super().__init__('invalid descriptor. {message}'.format(message=message))


class MissingSessionError(Exception):
    """Excetion raised for when the user tries to access a database session before it is created."""

    def __init__(self):
        msg = """
        No session found! Either you are not currently in a request context,
        or you need to manually create a session context by using a `db` instance as
        a context manager e.g.:
        with db():
            db.session.query(User).all()
        """

        super().__init__(msg)


class SessionNotInitialisedError(Exception):
    """Exception raised when the user creates a new DB session without first initialising it."""

    def __init__(self):
        msg = """
        Session not initialised! Ensure that DBSessionMiddleware has been initialised before
        attempting database access.
        """

        super().__init__(msg)