public static HttpResponseMessage CreateCustomErrorResponse(this HttpRequestMessage request, HttpStatusCode httpStatusCode, string message, int?code = null)
        {
            var errmsg = new HttpStatusErrorMessage()
            {
                Code = code
                ,
                Message = message
            };

            return(request.CreateResponse(httpStatusCode, errmsg.ToString()));
        }
        public static HttpResponseMessage CreateCustomErrorResponse(this HttpRequestMessage request, HttpStatusCode httpStatusCode, Exception ex, int?code = null)
        {
            var errmsg = new HttpStatusErrorMessage()
            {
                Code = code ?? ex.HResult
                ,
                Message = ex.Message
                ,
                Innererror = ex
            };

            return(request.CreateResponse(httpStatusCode, errmsg.ToString()));
        }
 public static HttpResponseMessage CreateCustomErrorResponse(this HttpRequestMessage request, HttpStatusCode httpStatusCode, HttpStatusErrorMessage httpStatusErrorMessage)
 {
     return(request.CreateResponse(httpStatusCode, httpStatusErrorMessage.ToString()));
 }