File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
azure-storage-blobs/test/ut
inc/azure/storage/common/internal Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2264,4 +2264,20 @@ namespace Azure { namespace Storage { namespace Test {
2264
2264
blobProperties = versionClient.GetProperties ().Value ;
2265
2265
EXPECT_TRUE (blobProperties.HasLegalHold );
2266
2266
}
2267
+
2268
+ TEST_F (BlockBlobClientTest, InvalidVersionMessage_LIVEONLY_)
2269
+ {
2270
+ Blobs::BlobClientOptions options;
2271
+ options.ApiVersion = " 3015-11-11" ;
2272
+ auto blobClient = GetBlockBlobClientForTest (LowercaseRandomString (), options);
2273
+ try
2274
+ {
2275
+ blobClient.Download ();
2276
+ }
2277
+ catch (const StorageException& e)
2278
+ {
2279
+ EXPECT_EQ (e.ErrorCode , _internal::InvalidHeaderValueErrorCode);
2280
+ EXPECT_EQ (e.Message , _internal::InvalidVersionHeaderMessage);
2281
+ }
2282
+ }
2267
2283
}}} // namespace Azure::Storage::Test
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ namespace Azure { namespace Storage { namespace _internal {
21
21
constexpr static const char * HttpHeaderContentType = " content-type" ;
22
22
constexpr static const char * HttpHeaderContentLength = " content-length" ;
23
23
constexpr static const char * HttpHeaderContentRange = " content-range" ;
24
+ constexpr static const char * InvalidHeaderValueErrorCode = " InvalidHeaderValue" ;
25
+ constexpr static const char * InvalidVersionHeaderMessage
26
+ = " The provided service version is not enabled on this storage account. Please see "
27
+ " https://learn.microsoft.com/rest/api/storageservices/"
28
+ " versioning-for-the-azure-storage-services for additional information." ;
24
29
25
30
constexpr int ReliableStreamRetryCount = 3 ;
26
31
}}} // namespace Azure::Storage::_internal
Original file line number Diff line number Diff line change @@ -147,6 +147,14 @@ namespace Azure { namespace Storage {
147
147
errorCode = response->GetHeaders ().at (" x-ms-error-code" );
148
148
}
149
149
150
+ // Optimize error messages
151
+ const auto headerName = additionalInformation.find (" HeaderName" );
152
+ if (errorCode == _internal::InvalidHeaderValueErrorCode
153
+ && headerName != additionalInformation.end () && headerName->second == " x-ms-version" )
154
+ {
155
+ message = _internal::InvalidVersionHeaderMessage;
156
+ }
157
+
150
158
StorageException result = StorageException (
151
159
std::to_string (static_cast <std::underlying_type<Azure::Core::Http::HttpStatusCode>::type>(
152
160
httpStatusCode))
You can’t perform that action at this time.
0 commit comments