37 lines
1.2 KiB
Python
37 lines
1.2 KiB
Python
from rest_framework import status
|
|
from rest_framework.exceptions import APIException
|
|
|
|
|
|
class UniqueRancherApiException(APIException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "دامدار با این کد ملی از قبل در سیستم وجود دارد" # noqa
|
|
|
|
|
|
class DuplicateRancherException(APIException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "اطلاعات دامدار استعلام شده دارای مشکل میباشد با پشتیبانی تماس بگیرید" # noqa
|
|
|
|
|
|
class HerdCapacityException(APIException):
|
|
status_code = status.HTTP_403_FORBIDDEN
|
|
default_detail = "مقدار حجم سبک و سنگین وارد شده از ظرفیت گله بیشتر میباشد" # noqa
|
|
|
|
|
|
class HerdException(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)
|