22 lines
560 B
Python
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'
|