using Nest; using System; using System.Text; namespace Sony.Filtr.AdminSearch { [Serializable] public class ElasticSearchException : Exception { public ElasticSearchException(string message, IBulkResponse response) : base(CreateErrorMessage(message, response)) { } private static string CreateErrorMessage(string message, IBulkResponse response) { StringBuilder builder = new StringBuilder(message); if (response.Errors) { builder.AppendLine(response.DebugInformation); foreach (var error in response.ItemsWithErrors) { builder.AppendLine($"Operation: {error.Operation} CausedBy: {error.Error.CausedBy?.Reason} Reason: {error.Error.Reason}"); } } return builder.ToString(); } } }