public override void OnException(HttpActionExecutedContext context) { if (context.Exception is EntityErrorsException) { var e = (EntityErrorsException)context.Exception; var error = new SaveError(e.Message, e.EntityErrors); var resp = new HttpResponseMessage(e.StatusCode) { Content = new ObjectContent(typeof(SaveError), error, JsonFormatter.Create()), }; context.Response = resp; } }