from rest_framework import status
from rest_framework.exceptions import APIException


class CRMException(APIException):
    status_code = status.HTTP_400_BAD_REQUEST

    def __init__(self, detail=None):
        if detail is None:
            detail = self.default_detail

        self.detail = {'error': detail}


class AuthErrorMixin(CRMException):
    """Authentication exception error mixin."""
    status_code = status.HTTP_401_UNAUTHORIZED


class InvalidCredentialsException(AuthErrorMixin):
    default_detail = 'cannot find the worker'
