< Summary

Class:Azure.Search.Documents.Models.SearchError
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchError.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchError.Serialization.cs
Covered lines:18
Uncovered lines:12
Coverable lines:30
Total lines:96
Line coverage:60% (18 of 30)
Covered branches:6
Total branches:12
Branch coverage:50% (6 of 12)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%100%
get_Code()-100%100%
get_Message()-100%100%
get_Details()-0%100%
DeserializeSearchError(...)-68.75%60%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchError.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Models
 13{
 14    /// <summary> Describes an error condition for the Azure Cognitive Search API. </summary>
 15    internal partial class SearchError
 16    {
 17        /// <summary> Initializes a new instance of SearchError. </summary>
 18        /// <param name="message"> A human-readable representation of the error. </param>
 19        /// <exception cref="ArgumentNullException"> <paramref name="message"/> is null. </exception>
 020        internal SearchError(string message)
 21        {
 022            if (message == null)
 23            {
 024                throw new ArgumentNullException(nameof(message));
 25            }
 26
 027            Message = message;
 028            Details = new ChangeTrackingList<SearchError>();
 029        }
 30
 31        /// <summary> Initializes a new instance of SearchError. </summary>
 32        /// <param name="code"> One of a server-defined set of error codes. </param>
 33        /// <param name="message"> A human-readable representation of the error. </param>
 34        /// <param name="details"> An array of details about specific errors that led to this reported error. </param>
 1935        internal SearchError(string code, string message, IReadOnlyList<SearchError> details)
 36        {
 1937            Code = code;
 1938            Message = message;
 1939            Details = details;
 1940        }
 41
 42        /// <summary> One of a server-defined set of error codes. </summary>
 1943        public string Code { get; }
 44        /// <summary> A human-readable representation of the error. </summary>
 1945        public string Message { get; }
 46        /// <summary> An array of details about specific errors that led to this reported error. </summary>
 047        public IReadOnlyList<SearchError> Details { get; }
 48    }
 49}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\SearchError.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Models
 13{
 14    internal partial class SearchError
 15    {
 16        internal static SearchError DeserializeSearchError(JsonElement element)
 17        {
 1918            Optional<string> code = default;
 1919            string message = default;
 1920            Optional<IReadOnlyList<SearchError>> details = default;
 11421            foreach (var property in element.EnumerateObject())
 22            {
 3823                if (property.NameEquals("code"))
 24                {
 1925                    code = property.Value.GetString();
 1926                    continue;
 27                }
 1928                if (property.NameEquals("message"))
 29                {
 1930                    message = property.Value.GetString();
 1931                    continue;
 32                }
 033                if (property.NameEquals("details"))
 34                {
 035                    List<SearchError> array = new List<SearchError>();
 036                    foreach (var item in property.Value.EnumerateArray())
 37                    {
 038                        array.Add(DeserializeSearchError(item));
 39                    }
 040                    details = array;
 41                    continue;
 42                }
 43            }
 1944            return new SearchError(code.Value, message, Optional.ToList(details));
 45        }
 46    }
 47}