Source code for api.users.exceptions
from django.utils.translation import gettext_lazy as _
from rest_framework.exceptions import APIException
[docs]
class AlreadyFollowingUserAPIException(APIException):
    """
    API Exception to be raised when a user attempts to follow a user that they are already following.
    """
    status_code = 400
    default_detail = _("You are already following this user.")
    default_code = "already_following_user" 
[docs]
class NotFollowingUserAPIException(APIException):
    """
    API Exception to be raised when a user attempts to unfollow a user that they are not following.
    """
    status_code = 400
    default_detail = _("You are not following to this user, so you can't unsubscribe from them.")
    default_code = "not_following_user"