title: What are the best practices for sending error responses in JSON web services?
body: <p>What is the best practice with regard to sending error responses in a JSON web service? I have seen it done several ways and wanted to know whether there were any agreed-upon standards or best practices among the choices.</p>
  
  <p>I've seen it done where the response includes indication of success or failure as well as the data to be returned or a suitable error message, e.g.</p>
  
  <pre><code>[{'success':true, 'data':{...}]
  [{'success':false, 'data':{'message':'error'}]
  </code></pre>
  
  <p>But I've also seen examples where the JSON object only includes data, and the service uses the normal HTTP error codes to indicate a problem (403, 404, 500, etc). (This is how the Twitter API does it.)</p>
  
  <p>Is there a "right" way to do this, or is it just a matter of style? Is the latter method more "RESTful?"</p>