def is_login_exception()

in aws_advanced_python_wrapper/utils/pg_exception_handler.py [0:0]


    def is_login_exception(self, error: Optional[Exception] = None, sql_state: Optional[str] = None) -> bool:
        if error:
            if isinstance(error, InvalidAuthorizationSpecification) or isinstance(error, InvalidPassword):
                return True

            if sql_state is None and hasattr(error, "sqlstate") and error.sqlstate is not None:
                sql_state = error.sqlstate

            if sql_state is not None and sql_state in self._ACCESS_ERRORS:
                return True

            if isinstance(error, OperationalError):
                if len(error.args) == 0:
                    return False

                # Check the error message if this is a generic error
                error_msg: str = error.args[0]
                if self._PASSWORD_AUTHENTICATION_FAILED_MSG in error_msg \
                        or self._PAM_AUTHENTICATION_FAILED_MSG in error_msg:
                    return True

        return False