Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
30 lines
660 B
Python
Executable File
30 lines
660 B
Python
Executable File
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)
|