def METHOD_NAME(req, *args, **kwargs):
    try:
        return view_func(req, *args, **kwargs)
    except Http404 as e:
        if str(e):
            return HttpResponse(json.dumps({"error": str(e)}),
                            content_type="application/json",
                            status=404)
        return HttpResponse(json.dumps({"error": "not authorized"}),
                            content_type="application/json",
                            status=401)