コード例 #1
0
 public HttpResponseError(HttpStatusCode status = HttpStatusCode.InternalServerError, string message = null, string error = null, string trace = null)
 {
     this.StatusCode = status;
     this.Error      = error ?? status.GetDefaultExceptionMessage();
     this.Message    = message ?? status.GetDefaultMessage();
     this.Trace      = trace;
 }
コード例 #2
0
 public HttpResponseError(ModelStateDictionary modelState, HttpStatusCode status = HttpStatusCode.InternalServerError)
 {
     this.StatusCode = status;
     this.Error      = status.GetDefaultExceptionMessage();
     if (modelState != null && modelState.Any(m => m.Value.Errors.Count > 0))
     {
         this.Message = String.Join(" ", modelState.SelectMany(m => m.Value.Errors).Select(e => e.ErrorMessage));
     }
 }