internal InnerError(string code, string message, string errorDetail, InnerError innerErrorValue)
 {
     Code            = code;
     Message         = message;
     ErrorDetail     = errorDetail;
     InnerErrorValue = innerErrorValue;
 }
Beispiel #2
0
 internal Error(string code, string message, string target, IReadOnlyList <Error> details, InnerError innererror, DateTimeOffset?occurredDateTime)
 {
     Code             = code;
     Message          = message;
     Target           = target;
     Details          = details;
     Innererror       = innererror;
     OccurredDateTime = occurredDateTime;
 }
        internal static Error DeserializeError(JsonElement element)
        {
            string            code    = default;
            string            message = default;
            Optional <string> target  = default;
            Optional <IReadOnlyList <Error> > details          = default;
            Optional <InnerError>             innererror       = default;
            Optional <DateTimeOffset>         occurredDateTime = 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("target"))
                {
                    target = 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;
                }
                if (property.NameEquals("occurredDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    occurredDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new Error(code, message, target.Value, Optional.ToList(details), innererror.Value, Optional.ToNullable(occurredDateTime)));
        }
 public static InnerError InnerError(string code = null, string message = null, string errorDetail = null, InnerError innerErrorValue = null)
 {
     return(new InnerError(code, message, errorDetail, innerErrorValue));
 }
        public static Error Error(string code = null, string message = null, string target = null, IEnumerable <Error> details = null, InnerError innererror = null, DateTimeOffset?occurredDateTime = null)
        {
            details ??= new List <Error>();

            return(new Error(code, message, target, details?.ToList(), innererror, occurredDateTime));
        }