fix - custom APIExceptions for quota stats
This commit is contained in:
@@ -2,6 +2,44 @@ from rest_framework import status
|
||||
from rest_framework.exceptions import APIException
|
||||
|
||||
|
||||
class QuotaException(APIException):
|
||||
""" if quota is not available """
|
||||
|
||||
status_code = status.HTTP_400_BAD_REQUEST
|
||||
default_detail = "خطا در اطلاعات سهمیه" # noqa
|
||||
default_code = 'error'
|
||||
|
||||
def __init__(self, message=None, status_code=None, code=None):
|
||||
if status_code is not None:
|
||||
self.status_code = status_code
|
||||
|
||||
detail = {
|
||||
"message": message,
|
||||
"status_code": status_code
|
||||
}
|
||||
|
||||
super().__init__(detail)
|
||||
|
||||
|
||||
class DistributionException(APIException):
|
||||
""" if distribution is not available """
|
||||
|
||||
status_code = status.HTTP_400_BAD_REQUEST
|
||||
default_detail = "خطا در اطلاعات توزیع." # noqa
|
||||
default_code = 'error'
|
||||
|
||||
def __init__(self, message=None, status_code=None, code=None):
|
||||
if status_code is not None:
|
||||
self.status_code = status_code
|
||||
|
||||
detail = {
|
||||
"message": message,
|
||||
"status_code": status_code
|
||||
}
|
||||
|
||||
super().__init__(detail)
|
||||
|
||||
|
||||
class QuotaWeightException(APIException):
|
||||
""" if quota distributions weight is more """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user