Files
eggs-backend/core/utils/exception.py
husanjon ab73d05ecc
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
gold eggs backend
2026-04-15 08:59:36 +02:00

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)