19 lines
465 B
Python
19 lines
465 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 Forbidden(CRMException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
|
|
# TODO: exceptions with a same template: ok / error_code / error_message
|