gold eggs backend
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
This commit is contained in:
29
core/utils/exception.py
Executable file
29
core/utils/exception.py
Executable file
@@ -0,0 +1,29 @@
|
||||
from rest_framework import status
|
||||
|
||||
from core import exceptions
|
||||
|
||||
|
||||
class ResponseException:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
message="",
|
||||
data=None,
|
||||
error_code=0,
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
exception=None,
|
||||
**kwargs
|
||||
):
|
||||
if isinstance(exception, exceptions.BreakException):
|
||||
raise exception
|
||||
|
||||
if data is None:
|
||||
data = []
|
||||
response = {
|
||||
"success": False,
|
||||
"message": message,
|
||||
"data": data,
|
||||
"error_code": error_code,
|
||||
**kwargs,
|
||||
}
|
||||
raise exceptions.MyApiException(response, status_code)
|
||||
Reference in New Issue
Block a user