| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.Text.Json; |
| | | 5 | | |
| | | 6 | | namespace Azure.Security.KeyVault.Certificates |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// An error encountered during the processing of a <see cref="CertificateOperation"/>. |
| | | 10 | | /// </summary> |
| | | 11 | | public class CertificateOperationError : IJsonDeserializable |
| | | 12 | | { |
| | | 13 | | private const string CodePropertyName = "code"; |
| | | 14 | | private const string MessagePropertyName = "message"; |
| | | 15 | | private const string InnerErrorPropertyName = "innererror"; |
| | | 16 | | |
| | 4 | 17 | | internal CertificateOperationError() |
| | | 18 | | { |
| | 4 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets the error code of the specified error. |
| | | 23 | | /// </summary> |
| | 0 | 24 | | public string Code { get; internal set; } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets a message containing details of the encountered error. |
| | | 28 | | /// </summary> |
| | 8 | 29 | | public string Message { get; internal set; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets an underlying error - if one exists - for the current error. |
| | | 33 | | /// </summary> |
| | 0 | 34 | | public CertificateOperationError InnerError { get; internal set; } |
| | | 35 | | |
| | | 36 | | void IJsonDeserializable.ReadProperties(JsonElement json) |
| | | 37 | | { |
| | 24 | 38 | | foreach (JsonProperty prop in json.EnumerateObject()) |
| | | 39 | | { |
| | 8 | 40 | | switch (prop.Name) |
| | | 41 | | { |
| | | 42 | | case CodePropertyName: |
| | 4 | 43 | | Code = prop.Value.GetString(); |
| | 4 | 44 | | break; |
| | | 45 | | |
| | | 46 | | case MessagePropertyName: |
| | 4 | 47 | | Message = prop.Value.GetString(); |
| | 4 | 48 | | break; |
| | | 49 | | |
| | | 50 | | case InnerErrorPropertyName: |
| | 0 | 51 | | InnerError = new CertificateOperationError(); |
| | 0 | 52 | | ((IJsonDeserializable)InnerError).ReadProperties(prop.Value); |
| | | 53 | | break; |
| | | 54 | | } |
| | | 55 | | } |
| | 4 | 56 | | } |
| | | 57 | | } |
| | | 58 | | } |