title: What is better WebAPI error response
body: <pre><code>1. return Request.CreateErrorResponse(HttpStatusCode.NotFound, "No product with ID = 1");
  
  2. var resp = new HttpResponseMessage(HttpStatusCode.NotFound) { Content = new StringContent("No product with ID = 1") };
     throw new HttpResponseException(resp);
  </code></pre>
  
  <p><a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling" rel="nofollow">This guideline</a> for exception handling in WebAPI describes both of above approaches. </p>
  
  <p>When should we <code>return Request.CreateErrorResponse</code> (#1) and when should we <code>throw an HttpResponseException</code> (#2)?</p>