Skip to content

Commit 77ebfeb

Browse files
committed
[Storage] Show more error information when cmdlet failed with StorageException.
1 parent ae7607e commit 77ebfeb

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Show more error information when cmdlet failed with StorageException
22+
23+
## Version 1.4.0
2124
* Support Kind FileStorage and SkuName Premium_ZRS when create Storage account
2225
- New-AzStorageAccount
2326
* Clarified description of blob immutability cmdlet

src/Storage/Storage/Common/StorageExceptionUtil.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,28 @@ public static StorageException RepackStorageException(this StorageException e)
7777
e.Message,
7878
e.RequestInformation.HttpStatusCode,
7979
e.RequestInformation.HttpStatusMessage);
80+
81+
if (e.RequestInformation.ExtendedErrorInformation != null)
82+
{
83+
String extendErrorInfo = String.Format(
84+
"\nErrorCode: {0}\nErrorMessage: {1}",
85+
e.RequestInformation.ExtendedErrorInformation.ErrorCode,
86+
e.RequestInformation.ExtendedErrorInformation.ErrorMessage);
87+
88+
if (e.RequestInformation.ExtendedErrorInformation.AdditionalDetails != null
89+
&& e.RequestInformation.ExtendedErrorInformation.AdditionalDetails.Count > 0)
90+
{
91+
string additionalDetails = string.Empty;
92+
foreach (var key in e.RequestInformation.ExtendedErrorInformation.AdditionalDetails)
93+
{
94+
additionalDetails += String.Format("\n{0}: {1}", key.Key, key.Value);
95+
}
96+
extendErrorInfo += additionalDetails;
97+
}
98+
msg += extendErrorInfo;
99+
}
80100
e = new StorageException(e.RequestInformation, msg, e);
81101
}
82-
83102
return e;
84103
}
85104
}

0 commit comments

Comments
 (0)