< Summary

Class:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Models.ErrorResponse
Assembly:Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Customizations\Models\ErrorResponse.cs
C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Models\ErrorResponse.cs
Covered lines:9
Uncovered lines:19
Coverable lines:28
Total lines:131
Line coverage:32.1% (9 of 28)
Covered branches:4
Total branches:16
Branch coverage:25% (4 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Code()-100%100%
get_Message()-0%0%
GetCodeFromAdditionalProperties()-42.86%33.33%
GetMessageFromAdditionalProperties()-0%0%
.ctor()-100%100%
.ctor(...)-0%100%
get_AdditionalProperties()-100%100%
get_ErrorType()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Customizations\Models\ErrorResponse.cs

#LineLine coverage
 1namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Models
 2{
 3    using Newtonsoft.Json;
 4
 5    public partial class ErrorResponse
 6    {
 7        private string code;
 8        private string message;
 9
 10        /// <summary>
 11        /// Error code.
 12        /// </summary>
 13        public string Code
 14        {
 15            get
 16            {
 517                if (code == null)
 18                {
 519                    code = GetCodeFromAdditionalProperties();
 20                }
 521                return code;
 22            }
 23        }
 24
 25        /// <summary>
 26        /// A description of the error.
 27        /// </summary>
 28        public string Message
 29        {
 30            get
 31            {
 032                if (message == null)
 33                {
 034                    message = GetMessageFromAdditionalProperties();
 35                }
 036                return message;
 37            }
 38        }
 39
 40        private string GetCodeFromAdditionalProperties()
 41        {
 042            if (AdditionalProperties == null) return "Generic error";
 543            if (AdditionalProperties.TryGetValue("error", out object data))
 44            {
 545                var error = JsonConvert.DeserializeObject<OperationError>(data.ToString());
 546                return error.Code;
 47            }
 048            if (AdditionalProperties.TryGetValue("statusCode", out data))
 49            {
 050                return data.ToString();
 51            }
 052            return "Generic error";
 53        }
 54
 55        private string GetMessageFromAdditionalProperties()
 56        {
 057            if (AdditionalProperties == null) return "Generic error";
 058            if (AdditionalProperties.TryGetValue("error", out object data))
 59            {
 060                var error = JsonConvert.DeserializeObject<OperationError>(data.ToString());
 061                return error.Message;
 62            }
 063            if (AdditionalProperties.TryGetValue("message", out data))
 64            {
 065                return data.ToString();
 66            }
 067            return "Generic message";
 68        }
 69    }
 70}

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Language.LUIS.Authoring\src\Generated\Models\ErrorResponse.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.CognitiveServices.Language.LUIS.Authoring.Models
 12{
 13    using Newtonsoft.Json;
 14    using System.Collections;
 15    using System.Collections.Generic;
 16    using System.Linq;
 17
 18    /// <summary>
 19    /// Error response when invoking an operation on the API.
 20    /// </summary>
 21    public partial class ErrorResponse
 22    {
 23        /// <summary>
 24        /// Initializes a new instance of the ErrorResponse class.
 25        /// </summary>
 526        public ErrorResponse()
 27        {
 28            CustomInit();
 529        }
 30
 31        /// <summary>
 32        /// Initializes a new instance of the ErrorResponse class.
 33        /// </summary>
 34        /// <param name="additionalProperties">Unmatched properties from the
 35        /// message are deserialized this collection</param>
 036        public ErrorResponse(IDictionary<string, object> additionalProperties = default(IDictionary<string, object>), st
 37        {
 038            AdditionalProperties = additionalProperties;
 039            ErrorType = errorType;
 40            CustomInit();
 041        }
 42
 43        /// <summary>
 44        /// An initialization method that performs custom operations like setting defaults
 45        /// </summary>
 46        partial void CustomInit();
 47
 48        /// <summary>
 49        /// Gets or sets unmatched properties from the message are deserialized
 50        /// this collection
 51        /// </summary>
 52        [JsonExtensionData]
 2053        public IDictionary<string, object> AdditionalProperties { get; set; }
 54
 55        /// <summary>
 56        /// </summary>
 57        [JsonProperty(PropertyName = "errorType")]
 058        public string ErrorType { get; set; }
 59
 60    }
 61}