Parse storage error code for HEAD requests (#5372)
* Error code for HEAD requests * clang-format * Recording
This commit is contained in:
Родитель
00b30e3d86
Коммит
a448c94052
|
@ -2,5 +2,5 @@
|
|||
"AssetsRepo": "Azure/azure-sdk-assets",
|
||||
"AssetsRepoPrefixPath": "cpp",
|
||||
"TagPrefix": "cpp/storage",
|
||||
"Tag": "cpp/storage_f8b8f80b3c"
|
||||
"Tag": "cpp/storage_265ef7508a"
|
||||
}
|
||||
|
|
|
@ -1468,4 +1468,25 @@ namespace Azure { namespace Storage { namespace Test {
|
|||
= Blobs::BlobContainerClient(m_blobContainerClient->GetUrl(), credential, clientOptions);
|
||||
EXPECT_THROW(containerClient.GetProperties(), StorageException);
|
||||
}
|
||||
|
||||
TEST_F(BlobContainerClientTest, ErrorCode)
|
||||
{
|
||||
auto inexistent = m_blobContainerClient->GetBlobClient(RandomString());
|
||||
try
|
||||
{
|
||||
inexistent.GetProperties();
|
||||
}
|
||||
catch (StorageException& e)
|
||||
{
|
||||
EXPECT_EQ(e.ErrorCode, "BlobNotFound");
|
||||
}
|
||||
try
|
||||
{
|
||||
inexistent.Download();
|
||||
}
|
||||
catch (StorageException& e)
|
||||
{
|
||||
EXPECT_EQ(e.ErrorCode, "BlobNotFound");
|
||||
}
|
||||
}
|
||||
}}} // namespace Azure::Storage::Test
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
### Bugs Fixed
|
||||
|
||||
- Fixed a bug where exception error code was not parsed for `HEAD` requests.
|
||||
|
||||
### Other Changes
|
||||
|
||||
### Acknowledgments
|
||||
|
|
|
@ -141,6 +141,12 @@ namespace Azure { namespace Storage {
|
|||
}
|
||||
}
|
||||
|
||||
if (errorCode.empty()
|
||||
&& response->GetHeaders().find("x-ms-error-code") != response->GetHeaders().end())
|
||||
{
|
||||
errorCode = response->GetHeaders().at("x-ms-error-code");
|
||||
}
|
||||
|
||||
StorageException result = StorageException(
|
||||
std::to_string(static_cast<std::underlying_type<Azure::Core::Http::HttpStatusCode>::type>(
|
||||
httpStatusCode))
|
||||
|
|
Загрузка…
Ссылка в новой задаче