kwork-poizonstore/store/exceptions.py
2023-07-10 20:06:11 +04:00

22 lines
560 B
Python

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 UnauthorizedException(CRMException):
"""Authentication exception error mixin."""
status_code = status.HTTP_401_UNAUTHORIZED
class InvalidCredentialsException(UnauthorizedException):
default_detail = 'cannot find the worker'