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} # TODO: exceptions with a same template: ok / error_code / error_message