# Path: social/exceptions.py
# class SocialAuthBaseException(ValueError):
#     """Base class for pipeline exceptions."""
#     pass


import six
from django.conf import settings
from django.contrib import messages
from django.shortcuts import redirect
from social.exceptions import SocialAuthBaseException
# -*- coding: utf-8 -*-




class SocialAuthExceptionMiddleware(object):
    """Middleware that handles Social Auth AuthExceptions by providing the user
    with a message, logging an error, and redirecting to some next location.

    By default, the exception message itself is sent to the user and they are
    redirected to the location specified in the SOCIAL_AUTH_LOGIN_ERROR_URL
    setting.

    This middleware can be extended by overriding the get_message or
    get_redirect_uri methods, which each accept request and exception.
    """
    def process_exception(self, request, exception):
        self.strategy = getattr(request, 'strategy', None)
        if self.strategy is None or self.raise_exception(request, exception):
            return


# Path: social/exceptions.py
# class SocialAuthBaseException(ValueError):
#     """Base class for pipeline exceptions."""
#     pass


# Path: social/apps/django_app/middleware.py
import six
from django.conf import settings
from django.contrib import messages
from django.shortcuts import redirect
from social.exceptions import SocialAuthBaseException

# -*- coding: utf-8 -*-




class SocialAuthExceptionMiddleware(object):
    """Middleware that handles Social Auth AuthExceptions by providing the user
    with a message, logging an error, and redirecting to some next location.

    By default, the exception message itself is sent to the user and they are
    redirected to the location specified in the SOCIAL_AUTH_LOGIN_ERROR_URL
    setting.

    This middleware can be extended by overriding the get_message or
    get_redirect_uri methods, which each accept request and exception.
    """
    def process_exception(self, request, exception):
        self.strategy = getattr(request, 'strategy', None)
        if self.strategy is None or self.raise_exception(request, exception):
            return


        if isinstance(exception, SocialAuthBaseException):