title: It is possible to get backend custom error message with d3.json?
body: <p>I develop a django application where I have a d3js interactive tree. I use d3.json to get the tree data from the django view. I have create a decorator to check if user is logged to allowed the request or not. I have no problem when the user is logged but when the decorator return the jsonResponse with redirection url I have only the status error with the status description.</p>
  
  <p>I read d3js and promise documentation but I'm not found a answer to return a jsonresponse with my custom response.</p>
  
  <pre><code>d3.json(d.data.url).then(function(data) {
            // process data no problem
          }, function(error){
            console.log(error);
          });
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>def check_user_permission_js(view_function):
      @wraps(view_function)
      def wrapper(request, *args, **kwargs):
          if request.user.is_authenticated:
              return view_function(request, *args, **kwargs)
          messages.warning(request,
              "Your account doesn't have access to this page "
              + "or your session has expired. "
              + "To proceed, please login with an account that has access.")
          return JsonResponse({'not_authenticated': True,
                               'redirect_url': settings.LOGIN_URL,'data':[]}, status=500)
      return wrapper
  </code></pre>