|  |  | 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 |  |  | 
|  |  | 11 |  | namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models | 
|  |  | 12 |  | { | 
|  |  | 13 |  |     using Microsoft.Rest; | 
|  |  | 14 |  |     using Newtonsoft.Json; | 
|  |  | 15 |  |     using System.Collections; | 
|  |  | 16 |  |     using System.Collections.Generic; | 
|  |  | 17 |  |     using System.Linq; | 
|  |  | 18 |  |  | 
|  |  | 19 |  |     /// <summary> | 
|  |  | 20 |  |     /// The error object. As per Microsoft One API guidelines - | 
|  |  | 21 |  |     /// https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. | 
|  |  | 22 |  |     /// </summary> | 
|  |  | 23 |  |     public partial class Error | 
|  |  | 24 |  |     { | 
|  |  | 25 |  |         /// <summary> | 
|  |  | 26 |  |         /// Initializes a new instance of the Error class. | 
|  |  | 27 |  |         /// </summary> | 
|  | 0 | 28 |  |         public Error() | 
|  |  | 29 |  |         { | 
|  |  | 30 |  |             CustomInit(); | 
|  | 0 | 31 |  |         } | 
|  |  | 32 |  |  | 
|  |  | 33 |  |         /// <summary> | 
|  |  | 34 |  |         /// Initializes a new instance of the Error class. | 
|  |  | 35 |  |         /// </summary> | 
|  |  | 36 |  |         /// <param name="code">One of a server-defined set of error codes. | 
|  |  | 37 |  |         /// Possible values include: 'BadArgument', 'Forbidden', 'NotFound', | 
|  |  | 38 |  |         /// 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', | 
|  |  | 39 |  |         /// 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', | 
|  |  | 40 |  |         /// 'OperationNotFound', 'ServiceError', 'ValidationFailure', | 
|  |  | 41 |  |         /// 'ExtractionFailure'</param> | 
|  |  | 42 |  |         /// <param name="message">A human-readable representation of the | 
|  |  | 43 |  |         /// error.</param> | 
|  |  | 44 |  |         /// <param name="target">The target of the error.</param> | 
|  |  | 45 |  |         /// <param name="details">An array of details about specific errors | 
|  |  | 46 |  |         /// that led to this reported error.</param> | 
|  |  | 47 |  |         /// <param name="innerError">An object containing more specific | 
|  |  | 48 |  |         /// information than the current object about the error.</param> | 
|  | 0 | 49 |  |         public Error(string code, string message = default(string), string target = default(string), IList<Error> detail | 
|  |  | 50 |  |         { | 
|  | 0 | 51 |  |             Code = code; | 
|  | 0 | 52 |  |             Message = message; | 
|  | 0 | 53 |  |             Target = target; | 
|  | 0 | 54 |  |             Details = details; | 
|  | 0 | 55 |  |             InnerError = innerError; | 
|  |  | 56 |  |             CustomInit(); | 
|  | 0 | 57 |  |         } | 
|  |  | 58 |  |  | 
|  |  | 59 |  |         /// <summary> | 
|  |  | 60 |  |         /// An initialization method that performs custom operations like setting defaults | 
|  |  | 61 |  |         /// </summary> | 
|  |  | 62 |  |         partial void CustomInit(); | 
|  |  | 63 |  |  | 
|  |  | 64 |  |         /// <summary> | 
|  |  | 65 |  |         /// Gets or sets one of a server-defined set of error codes. Possible | 
|  |  | 66 |  |         /// values include: 'BadArgument', 'Forbidden', 'NotFound', | 
|  |  | 67 |  |         /// 'KbNotFound', 'Unauthorized', 'Unspecified', 'EndpointKeysError', | 
|  |  | 68 |  |         /// 'QuotaExceeded', 'QnaRuntimeError', 'SKULimitExceeded', | 
|  |  | 69 |  |         /// 'OperationNotFound', 'ServiceError', 'ValidationFailure', | 
|  |  | 70 |  |         /// 'ExtractionFailure' | 
|  |  | 71 |  |         /// </summary> | 
|  |  | 72 |  |         [JsonProperty(PropertyName = "code")] | 
|  | 0 | 73 |  |         public string Code { get; set; } | 
|  |  | 74 |  |  | 
|  |  | 75 |  |         /// <summary> | 
|  |  | 76 |  |         /// Gets or sets a human-readable representation of the error. | 
|  |  | 77 |  |         /// </summary> | 
|  |  | 78 |  |         [JsonProperty(PropertyName = "message")] | 
|  | 0 | 79 |  |         public string Message { get; set; } | 
|  |  | 80 |  |  | 
|  |  | 81 |  |         /// <summary> | 
|  |  | 82 |  |         /// Gets or sets the target of the error. | 
|  |  | 83 |  |         /// </summary> | 
|  |  | 84 |  |         [JsonProperty(PropertyName = "target")] | 
|  | 0 | 85 |  |         public string Target { get; set; } | 
|  |  | 86 |  |  | 
|  |  | 87 |  |         /// <summary> | 
|  |  | 88 |  |         /// Gets or sets an array of details about specific errors that led to | 
|  |  | 89 |  |         /// this reported error. | 
|  |  | 90 |  |         /// </summary> | 
|  |  | 91 |  |         [JsonProperty(PropertyName = "details")] | 
|  | 0 | 92 |  |         public IList<Error> Details { get; set; } | 
|  |  | 93 |  |  | 
|  |  | 94 |  |         /// <summary> | 
|  |  | 95 |  |         /// Gets or sets an object containing more specific information than | 
|  |  | 96 |  |         /// the current object about the error. | 
|  |  | 97 |  |         /// </summary> | 
|  |  | 98 |  |         [JsonProperty(PropertyName = "innerError")] | 
|  | 0 | 99 |  |         public InnerErrorModel InnerError { get; set; } | 
|  |  | 100 |  |  | 
|  |  | 101 |  |         /// <summary> | 
|  |  | 102 |  |         /// Validate the object. | 
|  |  | 103 |  |         /// </summary> | 
|  |  | 104 |  |         /// <exception cref="ValidationException"> | 
|  |  | 105 |  |         /// Thrown if validation fails | 
|  |  | 106 |  |         /// </exception> | 
|  |  | 107 |  |         public virtual void Validate() | 
|  |  | 108 |  |         { | 
|  | 0 | 109 |  |             if (Code == null) | 
|  |  | 110 |  |             { | 
|  | 0 | 111 |  |                 throw new ValidationException(ValidationRules.CannotBeNull, "Code"); | 
|  |  | 112 |  |             } | 
|  | 0 | 113 |  |             if (Details != null) | 
|  |  | 114 |  |             { | 
|  | 0 | 115 |  |                 foreach (var element in Details) | 
|  |  | 116 |  |                 { | 
|  | 0 | 117 |  |                     if (element != null) | 
|  |  | 118 |  |                     { | 
|  | 0 | 119 |  |                         element.Validate(); | 
|  |  | 120 |  |                     } | 
|  |  | 121 |  |                 } | 
|  |  | 122 |  |             } | 
|  | 0 | 123 |  |         } | 
|  |  | 124 |  |     } | 
|  |  | 125 |  | } |