/// <summary> /// Build response for <see cref="RequestValidationException"/>. /// </summary> /// <param name="ex">Exception information about an error that happened in the WebApi project.</param> private static Task BuildAndSendAsync(RequestValidationException ex, ErrorBuilder errorBuilder) { foreach (var error in ex.Errors) { errorBuilder.AddData($"Invalid property: {error.PropertyName}", string.Join("; ", error.Messages)); } return(errorBuilder .SetDescription("Invalid request parameters") .SetHttpCode(HttpStatusCode.BadRequest) .SetErrorCode("RequestValidationError") .BuildAndSendAsync()); }