title: How to throw an ajax error with ASP.NET MVC3
body: <p>I want to handle all server-side errors with jQuery on client side. For this purpose a create axception handling attrbute for my MVC3 application like this:</p>
  
  <pre><code>public class JsonErrorHandlerAttribute : HandleErrorAttribute
  {
      public override void OnException(ExceptionContext filterContext)
      {
          filterContext.ExceptionHandled = true;
          JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
          string result = jsSerializer.Serialize(new { error = filterContext.Exception.Message });
          filterContext.HttpContext.Response.Write(result);
      }
  }
  </code></pre>
  
  <p>But with this approach it just returns normal json response with 200 OK result. A don't want to parse it on client side to determine if it has an error or not. So my question is what is the best way to throw an ajax error?</p>