Source code for apps.api.middleware.exception_handling

from apps.api.exceptions import ApiException, ValidationException
from rest_framework.views import exception_handler
from rest_framework.response import Response


[docs]def exception_handling(exc, context): response = exception_handler(exc, context) if isinstance(exc, ApiException): return Response(exc.message, exc.status_code) if isinstance(exc, ValidationException): return Response(exc.message, exc.status_code) return response