internal static SparkServiceError DeserializeSparkServiceError(JsonElement element)
        {
            Optional <string>           message   = default;
            Optional <string>           errorCode = default;
            Optional <SparkErrorSource> source    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("message"))
                {
                    message = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorCode"))
                {
                    errorCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    source = new SparkErrorSource(property.Value.GetString());
                    continue;
                }
            }
            return(new SparkServiceError(message.Value, errorCode.Value, Optional.ToNullable(source)));
        }
Esempio n. 2
0
        internal static SparkServiceError DeserializeSparkServiceError(JsonElement element)
        {
            string           message   = default;
            string           errorCode = default;
            SparkErrorSource?source    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("message"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    message = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    errorCode = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    source = new SparkErrorSource(property.Value.GetString());
                    continue;
                }
            }
            return(new SparkServiceError(message, errorCode, source));
        }