Skip to content

Commit

Permalink
Clarified error message when updating purged secret
Browse files Browse the repository at this point in the history
  • Loading branch information
BethanyZhou committed Apr 25, 2021
1 parent 5a79ab3 commit 052de4f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/KeyVault/KeyVault/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions src/KeyVault/KeyVault/Models/KeyVaultDataServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 052de4f

Please sign in to comment.