internal static ErrorCause CreateErrorCause(IDictionary <string, object> dict, IJsonSerializerStrategy strategy) { var causedBy = new ErrorCause(); causedBy.FillValues(dict); if (dict.TryGetValue("caused_by", out var innerCausedBy)) { causedBy.CausedBy = (ErrorCause)strategy.DeserializeObject(innerCausedBy, typeof(ErrorCause)); } causedBy.Metadata = ErrorCauseMetadata.CreateCauseMetadata(dict, strategy); return(causedBy); }
internal static Error CreateError(IDictionary <string, object> dict, IJsonSerializerStrategy strategy) { var error = new Error(); error.FillValues(dict); if (dict.TryGetValue("caused_by", out var causedBy)) { error.CausedBy = (ErrorCause)strategy.DeserializeObject(causedBy, typeof(ErrorCause)); } if (dict.TryGetValue("headers", out var headers)) { var d = (IDictionary <string, string>)strategy.DeserializeObject(headers, typeof(IDictionary <string, string>)); if (d != null) { error.Headers = new ReadOnlyDictionary <string, string>(d); } } error.Metadata = ErrorCauseMetadata.CreateCauseMetadata(dict, strategy); return(ReadRootCause(dict, strategy, error)); }
internal static ErrorCauseMetadata CreateCauseMetadata(IDictionary <string, object> dict, IJsonSerializerStrategy strategy) { var m = new ErrorCauseMetadata(); if (dict.TryGetValue("license.expired.feature", out var feature)) { m.LicensedExpiredFeature = Convert.ToString(feature); } if (dict.TryGetValue("index", out var index)) { m.Index = Convert.ToString(index); } if (dict.TryGetValue("index_uuid", out var indexUUID)) { m.IndexUUID = Convert.ToString(indexUUID); } if (dict.TryGetValue("resource.type", out var resourceType)) { m.ResourceType = Convert.ToString(resourceType); } if (dict.TryGetValue("resource.id", out var resourceId)) { m.ResourceId = GetStringArray(resourceId, strategy); } if (dict.TryGetValue("shard", out var shard)) { m.Shard = Convert.ToInt32(shard); } if (dict.TryGetValue("line", out var line)) { m.Line = Convert.ToInt32(line); } if (dict.TryGetValue("col", out var column)) { m.Column = Convert.ToInt32(column); } if (dict.TryGetValue("bytes_wanted", out var bytesWanted)) { m.BytesWanted = Convert.ToInt64(bytesWanted); } if (dict.TryGetValue("bytes_limit", out var bytesLimit)) { m.BytesLimit = Convert.ToInt64(bytesLimit); } if (dict.TryGetValue("phase", out var phase)) { m.Phase = Convert.ToString(phase); } if (dict.TryGetValue("grouped", out var grouped)) { m.Grouped = Convert.ToBoolean(grouped); } if (dict.TryGetValue("script_stack", out var scriptStack)) { m.ScriptStack = GetStringArray(scriptStack, strategy); } if (dict.TryGetValue("script", out var script)) { m.Script = Convert.ToString(script); } if (dict.TryGetValue("lang", out var language)) { m.Language = Convert.ToString(language); } if (dict.TryGetValue("failed_shards", out var failedShards)) { m.FailedShards = GetShardFailures(failedShards, strategy); } return(m); }