public static HttpResponseException Create( HttpStatusCode statusCode, string source, ushort code, string description, params object[] details) { var fault = new ServiceFaultContract { Source = source, Code = code, Description = description }; if (details != null) { foreach (var detail in details) { fault.Details.Add(detail?.ToString()); } } return Create(statusCode, fault); }
public static HttpResponseException Create(HttpStatusCode statusCode, ServiceFaultContract fault) { var response = new HttpResponseMessage(statusCode) { Content = new ObjectContent<ServiceFaultContract>(fault, new JsonMediaTypeFormatter()) }; return new HttpResponseException(response); }