internal PersonalizerError(PersonalizerErrorCode code, string message, string target, IReadOnlyList <PersonalizerError> details, InternalError innerError)
 {
     Code       = code;
     Message    = message;
     Target     = target;
     Details    = details;
     InnerError = innerError;
 }
        internal PersonalizerError(PersonalizerErrorCode code, string message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            Code    = code;
            Message = message;
            Details = new ChangeTrackingList <PersonalizerError>();
        }
        internal static PersonalizerError DeserializePersonalizerError(JsonElement element)
        {
            PersonalizerErrorCode code = default;
            string            message  = default;
            Optional <string> target   = default;
            Optional <IReadOnlyList <PersonalizerError> > details = default;
            Optional <InternalError> innerError = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("code"))
                {
                    code = new PersonalizerErrorCode(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 <PersonalizerError> array = new List <PersonalizerError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializePersonalizerError(item));
                    }
                    details = array;
                    continue;
                }
                if (property.NameEquals("innerError"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    innerError = InternalError.DeserializeInternalError(property.Value);
                    continue;
                }
            }
            return(new PersonalizerError(code, message, target.Value, Optional.ToList(details), innerError.Value));
        }