title: Django ajax error response best practice
body: <p>I'm using ajax to improve user experience in my Django project. My concern here is how to respond error to browser properly. As far as I know, I can either:</p>
  
  <ol>
  <li>validate request data piece by piece and guard exception one by one. If something bad happens, raise Http404 or other exception to explicitly announce an error has occurred. Or</li>
  <li>just write code without exception handling and suppose it will work. If something bad happens, the uncaught exception would cause an internal server error, which is still an error for the browser</li>
  </ol>
  
  <p>For me, the fisrt method seems more orthodox , as in Python the philosophy of "Explicit is better than Implicit" really counts. But since all sorts of exception checking are removed from the second one, it is cleaner, less fragmented and more readable.</p>
  
  <p>I'm using jQuery to handle ajax request/response and both methods seem working. My questions are:</p>
  
  <ol>
  <li>Are both methods acceptable?</li>
  <li>Will the second method fail for other Javascript libraries?</li>
  <li>What is the best practice for this?</li>
  </ol>
  
  <p>PS. I do do essential data validation. Please do not stray the topic for that. :)</p>