def METHOD_NAME(exc, context):
    if isinstance(exc, dj_http.Http404):
        data = {
            'code': drf_exc.NotFound.default_code,
            'message': drf_exc.NotFound.default_detail,
        }
        views.set_rollback()
        return Response(data, status=http_codes.HTTP_404_NOT_FOUND)
    if isinstance(exc, dj_exc.PermissionDenied):
        data = {
            'code': drf_exc.PermissionDenied.default_code,
            'message': drf_exc.PermissionDenied.default_detail,
        }
        views.set_rollback()
        return Response(data, status=http_codes.HTTP_403_FORBIDDEN)
    if isinstance(exc, drf_exc.APIException):
        headers = {}
        if getattr(exc, 'auth_header', None):
            headers['WWW-Authenticate'] = exc.auth_header
        if getattr(exc, 'wait', None):
            headers['Retry-After'] = '%d' % exc.wait
        data = {
            'code': exc.default_code,
            'message': exc.default_detail,
        }
        errors = []
        if isinstance(exc.detail, list):
            errors = [{'code': e.code, 'message': e} for e in exc.detail]
        elif isinstance(exc.detail, dict):
            for field, messages in exc.detail.items():
                if isinstance(messages, str):
                    messages = [messages]
                for message in messages:
                    error = {'code': message.code, 'message': message}
                    if field != api_settings.NON_FIELD_ERRORS_KEY:
                        error['field'] = field
                    errors.append(error)
        else:
            data['code'] = exc.detail.code
            data['message'] = exc.detail
        if len(errors) == 1 and 'field' not in errors[0]:
            data.update(errors[0])
        elif errors:
            data['errors'] = errors
        views.set_rollback()
        return Response(data, status=exc.status_code, headers=headers)
    return None