internal static InnerError DeserializeInnerError(JsonElement element) { string code = default; InnerError innererror = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } code = property.Value.GetString(); continue; } if (property.NameEquals("innererror")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } innererror = DeserializeInnerError(property.Value); continue; } } return(new InnerError(code, innererror)); }
internal static Error DeserializeError(JsonElement element) { string code = default; string message = default; IReadOnlyList <Error> details = default; InnerError innererror = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } code = property.Value.GetString(); continue; } if (property.NameEquals("message")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } message = property.Value.GetString(); continue; } if (property.NameEquals("details")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <Error> array = new List <Error>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(DeserializeError(item)); } } details = array; continue; } if (property.NameEquals("innererror")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } innererror = InnerError.DeserializeInnerError(property.Value); continue; } } return(new Error(code, message, details, innererror)); }
internal Error(string code, string message, IReadOnlyList <Error> details, InnerError innererror) { Code = code; Message = message; Details = details; Innererror = innererror; }
internal static Error DeserializeError(JsonElement element) { Optional <string> code = default; Optional <string> message = default; Optional <IReadOnlyList <Error> > details = default; Optional <InnerError> innererror = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("code")) { code = property.Value.GetString(); continue; } if (property.NameEquals("message")) { message = property.Value.GetString(); continue; } if (property.NameEquals("details")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <Error> array = new List <Error>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DeserializeError(item)); } details = array; continue; } if (property.NameEquals("innererror")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } innererror = InnerError.DeserializeInnerError(property.Value); continue; } } return(new Error(code.Value, message.Value, Optional.ToList(details), innererror.Value)); }