From 052de4fd80e48b9368142897bc93440df92a49b5 Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Sun, 25 Apr 2021 15:21:16 +0800 Subject: [PATCH] Clarified error message when updating purged secret --- src/KeyVault/KeyVault/ChangeLog.md | 1 + src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/KeyVault/KeyVault/ChangeLog.md b/src/KeyVault/KeyVault/ChangeLog.md index bb0bbfc16e6b..6faa876b4b50 100644 --- a/src/KeyVault/KeyVault/ChangeLog.md +++ b/src/KeyVault/KeyVault/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Clarified error message when updating purged secret [#14800] ## Version 3.4.2 * Fixed a bug for `Get-AzKeyVaultSecret -AsPlainText` if the secret is not found [#14645] diff --git a/src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs b/src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs index 0f6f7b5fe801..8ab9b41ee486 100644 --- a/src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs +++ b/src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs @@ -20,6 +20,7 @@ using System.Net; using System.Security; using System.Security.Cryptography.X509Certificates; +using System.Text.RegularExpressions; using System.Xml; using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; @@ -1439,6 +1440,13 @@ public PSDeletedKeyVaultManagedStorageSasDefinition DeleteManagedStorageSasDefin private Exception GetInnerException(Exception exception) { while (exception.InnerException != null) exception = exception.InnerException; + if (exception is KeyVaultErrorException kvEx) + { + var detailedMsg = exception.Message; + detailedMsg += string.Format(Environment.NewLine + "ErrorCode: {0}", kvEx.Body.Error.Code); + detailedMsg += string.Format(Environment.NewLine + "ErrorMessage: {0}", kvEx.Body.Error.Message); + exception = new KeyVaultErrorException(detailedMsg, kvEx); + } return exception; }