def METHOD_NAME(exc, context):
    logger.exception(exc)
    response = exception_handler(exc, context)
    detail = getattr(exc, "detail", None)
    messages = message_handler(exc)
    status_code = getattr(exc, "status_code", status.HTTP_500_INTERNAL_SERVER_ERROR)
    code = get_code(exc)
    if isinstance(exc, exceptions.ValidationError) or isinstance(
        exc, sdk.ValidationError
    ):
        return Response(
            messages
            or dict(
                errors=lib.to_dict(
                    [
                        Error(
                            code=code or "validation",
                            message=detail if isinstance(detail, str) else None,
                            details=(detail if not isinstance(detail, str) else None),
                        )
                    ]
                )
            ),
            status=status.HTTP_400_BAD_REQUEST,
            headers=getattr(response, "headers", None),
        )
    if isinstance(exc, ObjectDoesNotExist):
        return Response(
            dict(
                errors=lib.to_dict(
                    [
                        Error(
                            code=code or "not_found",
                            message=detail if isinstance(detail, str) else None,
                            details=(detail if not isinstance(detail, str) else None),
                        )
                    ]
                )
            ),
            status=status.HTTP_404_NOT_FOUND,
            headers=getattr(response, "headers", None),
        )
    if isinstance(exc, APIExceptions):
        errors = error_handler(exc)
        if errors is not None:
            return Response(
                lib.to_dict(errors),
                status=status_code,
                headers=getattr(response, "headers", None),
            )
    if isinstance(exc, APIException) or isinstance(exc, exceptions.APIException):
        return Response(
            messages
            or dict(
                errors=lib.to_dict(
                    [
                        Error(
                            code=code,
                            message=detail if isinstance(detail, str) else None,
                            details=(detail if not isinstance(detail, str) else None),
                        )
                    ]
                )
            ),
            status=status_code,
            headers=getattr(response, "headers", None),
        )
    elif isinstance(exc, Exception):
        message, *_ = list(exc.args)
        return Response(
            dict(errors=lib.to_dict([Error(code=code, message=message)])),
            status=status_code,
            headers=getattr(response, "headers", None),
        )
    return response