From 1b132190ee55be5ffee286c906aaa46b29b45afc Mon Sep 17 00:00:00 2001 From: JinmingHu Date: Thu, 3 Jun 2021 10:46:28 +0800 Subject: [PATCH] unify message format of exception/assertion (#2382) * unify exception message * unify format of assertion message --- .../azure-storage-blobs/src/blob_client.cpp | 8 ++--- .../src/blob_lease_client.cpp | 30 ++++++++-------- .../src/blob_responses.cpp | 4 +-- .../src/blob_sas_builder.cpp | 2 +- .../src/block_blob_client.cpp | 4 +-- .../azure-storage-common/sample/main.cpp | 2 +- .../azure-storage-common/src/crypt.cpp | 20 +++++------ .../azure-storage-common/src/file_io.cpp | 28 +++++++-------- .../src/storage_credential.cpp | 2 +- .../azure-storage-common/src/xml_wrapper.cpp | 14 ++++---- .../azure-storage-common/test/test_base.cpp | 4 +-- .../src/datalake_file_client.cpp | 2 +- .../src/datalake_sas_builder.cpp | 2 +- .../src/share_file_client.cpp | 34 +++++++++---------- .../src/share_responses.cpp | 4 +-- .../src/share_sas_builder.cpp | 2 +- 16 files changed, 81 insertions(+), 81 deletions(-) diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index ca2bc625b..2bd48887d 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -258,14 +258,14 @@ namespace Azure { namespace Storage { namespace Blobs { if (static_cast(blobRangeSize) > bufferSize) { throw Azure::Core::RequestFailedException( - "buffer is not big enough, blob range size is " + std::to_string(blobRangeSize)); + "Buffer is not big enough, blob range size is " + std::to_string(blobRangeSize) + "."); } int64_t bytesRead = firstChunk.Value.BodyStream->ReadToCount( buffer, static_cast(firstChunkLength), context); if (bytesRead != firstChunkLength) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } firstChunk.Value.BodyStream.reset(); @@ -296,7 +296,7 @@ namespace Azure { namespace Storage { namespace Blobs { context); if (bytesRead != chunkOptions.Range.Value().Length.Value()) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } if (chunkId == numChunks - 1) @@ -376,7 +376,7 @@ namespace Azure { namespace Storage { namespace Blobs { size_t bytesRead = stream.ReadToCount(buffer.data(), readSize, context); if (bytesRead != readSize) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } fileWriter.Write(buffer.data(), bytesRead, offset); length -= bytesRead; diff --git a/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp index 1e38506d5..c0a9512a7 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp @@ -55,13 +55,13 @@ namespace Azure { namespace Storage { namespace Blobs { AZURE_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), - "Blob container lease doesn't support If-Match condition"); + "Blob container lease doesn't support If-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), - "Blob container lease doesn't support If-None-Match condition"); + "Blob container lease doesn't support If-None-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), - "Blob container lease doesn't support tag condition"); + "Blob container lease doesn't support tag condition."); auto response = _detail::BlobRestClient::BlobContainer::AcquireLease( *(m_blobContainerClient.Value().m_pipeline), @@ -120,13 +120,13 @@ namespace Azure { namespace Storage { namespace Blobs { AZURE_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), - "Blob container lease doesn't support If-Match condition"); + "Blob container lease doesn't support If-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), - "Blob container lease doesn't support If-None-Match condition"); + "Blob container lease doesn't support If-None-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), - "Blob container lease doesn't support tag condition"); + "Blob container lease doesn't support tag condition."); auto response = _detail::BlobRestClient::BlobContainer::RenewLease( *(m_blobContainerClient.Value().m_pipeline), @@ -184,13 +184,13 @@ namespace Azure { namespace Storage { namespace Blobs { AZURE_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), - "Blob container lease doesn't support If-Match condition"); + "Blob container lease doesn't support If-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), - "Blob container lease doesn't support If-None-Match condition"); + "Blob container lease doesn't support If-None-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), - "Blob container lease doesn't support tag condition"); + "Blob container lease doesn't support tag condition."); auto response = _detail::BlobRestClient::BlobContainer::ReleaseLease( *(m_blobContainerClient.Value().m_pipeline), @@ -256,13 +256,13 @@ namespace Azure { namespace Storage { namespace Blobs { AZURE_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), - "Blob container lease doesn't support If-Match condition"); + "Blob container lease doesn't support If-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), - "Blob container lease doesn't support If-None-Match condition"); + "Blob container lease doesn't support If-None-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), - "Blob container lease doesn't support tag condition"); + "Blob container lease doesn't support tag condition."); auto response = _detail::BlobRestClient::BlobContainer::ChangeLease( *(m_blobContainerClient.Value().m_pipeline), @@ -325,13 +325,13 @@ namespace Azure { namespace Storage { namespace Blobs { AZURE_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), - "Blob container lease doesn't support If-Match condition"); + "Blob container lease doesn't support If-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), - "Blob container lease doesn't support If-None-Match condition"); + "Blob container lease doesn't support If-None-Match condition."); AZURE_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), - "Blob container lease doesn't support tag condition"); + "Blob container lease doesn't support tag condition."); auto response = _detail::BlobRestClient::BlobContainer::BreakLease( *(m_blobContainerClient.Value().m_pipeline), diff --git a/sdk/storage/azure-storage-blobs/src/blob_responses.cpp b/sdk/storage/azure-storage-blobs/src/blob_responses.cpp index 9f59ecc14..ac248fed2 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_responses.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_responses.cpp @@ -50,11 +50,11 @@ namespace Azure { namespace Storage { namespace Blobs { } else if (m_status == Azure::Core::OperationStatus::Failed) { - throw Azure::Core::RequestFailedException("Operation failed"); + throw Azure::Core::RequestFailedException("Operation failed."); } else if (m_status == Azure::Core::OperationStatus::Cancelled) { - throw Azure::Core::RequestFailedException("Operation was cancelled"); + throw Azure::Core::RequestFailedException("Operation was cancelled."); } std::this_thread::sleep_for(period); diff --git a/sdk/storage/azure-storage-blobs/src/blob_sas_builder.cpp b/sdk/storage/azure-storage-blobs/src/blob_sas_builder.cpp index 4934f2198..c6e281910 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_sas_builder.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_sas_builder.cpp @@ -29,7 +29,7 @@ namespace Azure { namespace Storage { namespace Sas { } else { - throw std::invalid_argument("unknown BlobSasResource value"); + throw std::invalid_argument("Unknown BlobSasResource value."); } } } // namespace diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index 25d969ecb..c74babd00 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -150,7 +150,7 @@ namespace Azure { namespace Storage { namespace Blobs { } if (chunkSize > MaxStageBlockSize) { - throw Azure::Core::RequestFailedException("Block size is too big"); + throw Azure::Core::RequestFailedException("Block size is too big."); } std::vector blockIds; @@ -256,7 +256,7 @@ namespace Azure { namespace Storage { namespace Blobs { } if (chunkSize > MaxStageBlockSize) { - throw Azure::Core::RequestFailedException("Block size is too big"); + throw Azure::Core::RequestFailedException("Block size is too big."); } _internal::ConcurrentTransfer( diff --git a/sdk/storage/azure-storage-common/sample/main.cpp b/sdk/storage/azure-storage-common/sample/main.cpp index 7c3139905..b17271cf5 100644 --- a/sdk/storage/azure-storage-common/sample/main.cpp +++ b/sdk/storage/azure-storage-common/sample/main.cpp @@ -26,7 +26,7 @@ std::string GetConnectionString() { return envConnectionString; } - throw std::runtime_error("Cannot find connection string"); + throw std::runtime_error("Cannot find connection string."); } std::string GetAccountName() diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index ae6191827..f10ce3ae3 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -103,7 +103,7 @@ namespace Azure { namespace Storage { } else { - throw std::runtime_error("unknown algorithm type"); + throw std::runtime_error("Unknown algorithm type."); } unsigned long algorithmFlags = 0; @@ -115,7 +115,7 @@ namespace Azure { namespace Storage { = BCryptOpenAlgorithmProvider(&Handle, algorithmId, nullptr, algorithmFlags); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptOpenAlgorithmProvider failed"); + throw std::runtime_error("BCryptOpenAlgorithmProvider failed."); } DWORD objectLength = 0; DWORD dataLength = 0; @@ -128,7 +128,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptGetProperty failed"); + throw std::runtime_error("BCryptGetProperty failed."); } ContextSize = objectLength; DWORD hashLength = 0; @@ -141,7 +141,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptGetProperty failed"); + throw std::runtime_error("BCryptGetProperty failed."); } HashLength = hashLength; } @@ -167,7 +167,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptCreateHash failed"); + throw std::runtime_error("BCryptCreateHash failed."); } status = BCryptHashData( @@ -177,7 +177,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptHashData failed"); + throw std::runtime_error("BCryptHashData failed."); } std::vector hash; @@ -186,7 +186,7 @@ namespace Azure { namespace Storage { hashHandle, reinterpret_cast(&hash[0]), static_cast(hash.size()), 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptFinishHash failed"); + throw std::runtime_error("BCryptFinishHash failed."); } BCryptDestroyHash(hashHandle); @@ -215,7 +215,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptCreateHash failed"); + throw std::runtime_error("BCryptCreateHash failed."); } status = BCryptHashData( @@ -225,7 +225,7 @@ namespace Azure { namespace Storage { 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptHashData failed"); + throw std::runtime_error("BCryptHashData failed."); } std::vector hash; @@ -234,7 +234,7 @@ namespace Azure { namespace Storage { hashHandle, reinterpret_cast(&hash[0]), static_cast(hash.size()), 0); if (!BCRYPT_SUCCESS(status)) { - throw std::runtime_error("BCryptFinishHash failed"); + throw std::runtime_error("BCryptFinishHash failed."); } BCryptDestroyHash(hashHandle); diff --git a/sdk/storage/azure-storage-common/src/file_io.cpp b/sdk/storage/azure-storage-common/src/file_io.cpp index f15136599..e48fb2d59 100644 --- a/sdk/storage/azure-storage-common/src/file_io.cpp +++ b/sdk/storage/azure-storage-common/src/file_io.cpp @@ -34,7 +34,7 @@ namespace Azure { namespace Storage { namespace _internal { CP_UTF8, MB_ERR_INVALID_CHARS, filename.data(), int(filename.length()), nullptr, 0); if (sizeNeeded == 0) { - throw std::runtime_error("invalid filename"); + throw std::runtime_error("Invalid filename."); } std::wstring filenameW(sizeNeeded, L'\0'); if (MultiByteToWideChar( @@ -46,7 +46,7 @@ namespace Azure { namespace Storage { namespace _internal { sizeNeeded) == 0) { - throw std::runtime_error("invalid filename"); + throw std::runtime_error("Invalid filename."); } HANDLE fileHandle; @@ -66,7 +66,7 @@ namespace Azure { namespace Storage { namespace _internal { #endif if (fileHandle == INVALID_HANDLE_VALUE) { - throw std::runtime_error("failed to open file"); + throw std::runtime_error("Failed to open file."); } LARGE_INTEGER fileSize; @@ -74,7 +74,7 @@ namespace Azure { namespace Storage { namespace _internal { if (!ret) { CloseHandle(fileHandle); - throw std::runtime_error("failed to get size of file"); + throw std::runtime_error("Failed to get size of file."); } m_handle = static_cast(fileHandle); m_fileSize = fileSize.QuadPart; @@ -88,7 +88,7 @@ namespace Azure { namespace Storage { namespace _internal { CP_UTF8, MB_ERR_INVALID_CHARS, filename.data(), int(filename.length()), nullptr, 0); if (sizeNeeded == 0) { - throw std::runtime_error("invalid filename"); + throw std::runtime_error("Invalid filename."); } std::wstring filenameW(sizeNeeded, L'\0'); if (MultiByteToWideChar( @@ -100,7 +100,7 @@ namespace Azure { namespace Storage { namespace _internal { sizeNeeded) == 0) { - throw std::runtime_error("invalid filename"); + throw std::runtime_error("Invalid filename."); } HANDLE fileHandle; @@ -121,7 +121,7 @@ namespace Azure { namespace Storage { namespace _internal { #endif if (fileHandle == INVALID_HANDLE_VALUE) { - throw std::runtime_error("failed to open file"); + throw std::runtime_error("Failed to open file."); } m_handle = static_cast(fileHandle); } @@ -132,7 +132,7 @@ namespace Azure { namespace Storage { namespace _internal { { if (length > std::numeric_limits::max()) { - throw std::runtime_error("failed to write file"); + throw std::runtime_error("Failed to write file."); } OVERLAPPED overlapped; @@ -149,7 +149,7 @@ namespace Azure { namespace Storage { namespace _internal { &overlapped); if (!ret) { - throw std::runtime_error("failed to write file"); + throw std::runtime_error("Failed to write file."); } } #elif defined(AZ_PLATFORM_POSIX) @@ -158,13 +158,13 @@ namespace Azure { namespace Storage { namespace _internal { m_handle = open(filename.data(), O_RDONLY); if (m_handle == -1) { - throw std::runtime_error("failed to open file"); + throw std::runtime_error("Failed to open file."); } m_fileSize = lseek(m_handle, 0, SEEK_END); if (m_fileSize == -1) { close(m_handle); - throw std::runtime_error("failed to get size of file"); + throw std::runtime_error("Failed to get size of file."); } } @@ -176,7 +176,7 @@ namespace Azure { namespace Storage { namespace _internal { filename.data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (m_handle == -1) { - throw std::runtime_error("failed to open file"); + throw std::runtime_error("Failed to open file."); } } @@ -186,12 +186,12 @@ namespace Azure { namespace Storage { namespace _internal { { if (offset > static_cast(std::numeric_limits::max())) { - throw std::runtime_error("failed to write file"); + throw std::runtime_error("Failed to write file."); } ssize_t bytesWritten = pwrite(m_handle, buffer, length, static_cast(offset)); if (bytesWritten < 0 || static_cast(bytesWritten) != length) { - throw std::runtime_error("failed to write file"); + throw std::runtime_error("Failed to write file."); } } #endif diff --git a/sdk/storage/azure-storage-common/src/storage_credential.cpp b/sdk/storage/azure-storage-common/src/storage_credential.cpp index 2defb9bc3..775da1f6e 100644 --- a/sdk/storage/azure-storage-common/src/storage_credential.cpp +++ b/sdk/storage/azure-storage-common/src/storage_credential.cpp @@ -89,7 +89,7 @@ namespace Azure { namespace Storage { namespace _internal { { if (accountName.empty()) { - throw std::runtime_error("Cannot find account name in connection string"); + throw std::runtime_error("Cannot find account name in connection string."); } connectionStringParts.KeyCredential = std::make_shared(accountName, accountKey); diff --git a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp index fc22de718..d6e8fd3a1 100644 --- a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp +++ b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp @@ -25,13 +25,13 @@ namespace Azure { namespace Storage { namespace _internal { if (length > static_cast(std::numeric_limits::max())) { - throw std::runtime_error("xml data too big"); + throw std::runtime_error("Xml data too big."); } m_reader = xmlReaderForMemory(data, static_cast(length), nullptr, nullptr, 0); if (!m_reader) { - throw std::runtime_error("failed to parse xml"); + throw std::runtime_error("Failed to parse xml."); } } @@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace _internal { } else { - throw std::runtime_error("failed to parse xml"); + throw std::runtime_error("Failed to parse xml."); } } @@ -66,7 +66,7 @@ namespace Azure { namespace Storage { namespace _internal { } if (ret != 1) { - throw std::runtime_error("failed to parse xml"); + throw std::runtime_error("Failed to parse xml."); } int type = xmlTextReaderNodeType(reader); @@ -107,7 +107,7 @@ namespace Azure { namespace Storage { namespace _internal { } else { - throw std::runtime_error("unknown type " + std::to_string(type) + " while parsing xml"); + throw std::runtime_error("Unknown type " + std::to_string(type) + " while parsing xml."); } return Read(); @@ -172,8 +172,8 @@ namespace Azure { namespace Storage { namespace _internal { else { throw std::runtime_error( - "unsupported XmlNode type " - + std::to_string(static_cast::type>(node.Type))); + "Unsupported XmlNode type " + + std::to_string(static_cast::type>(node.Type)) + "."); } } diff --git a/sdk/storage/azure-storage-common/test/test_base.cpp b/sdk/storage/azure-storage-common/test/test_base.cpp index 665f4cf72..93ae9ac04 100644 --- a/sdk/storage/azure-storage-common/test/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/test_base.cpp @@ -246,7 +246,7 @@ namespace Azure { namespace Storage { namespace Test { FILE* fin = fopen(filename.data(), "rb"); if (!fin) { - throw std::runtime_error("failed to open file"); + throw std::runtime_error("Failed to open file."); } fseek(fin, 0, SEEK_END); int64_t fileSize = ftell(fin); @@ -255,7 +255,7 @@ namespace Azure { namespace Storage { namespace Test { size_t elementsRead = fread(fileContent.data(), static_cast(fileSize), 1, fin); if (elementsRead != 1 && fileSize != 0) { - throw std::runtime_error("failed to read file"); + throw std::runtime_error("Failed to read file."); } fclose(fin); return fileContent; diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp index ead83caa5..59f548958 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp @@ -379,7 +379,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { protocolLayerOptions.ExpiryOrigin = expiryOrigin; AZURE_ASSERT_MSG( !(options.ExpiresOn.HasValue() && options.TimeToExpire.HasValue()), - "ExpiresOn and TimeToExpire are mutually exclusive"); + "ExpiresOn and TimeToExpire are mutually exclusive."); if (options.ExpiresOn.HasValue()) { diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_sas_builder.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_sas_builder.cpp index 0c9535c0a..22c76eff3 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_sas_builder.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_sas_builder.cpp @@ -24,7 +24,7 @@ namespace Azure { namespace Storage { namespace Sas { } else { - throw std::invalid_argument("unknown DataLakeSasResource value"); + throw std::invalid_argument("Unknown DataLakeSasResource value."); } } } // namespace diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index ef25cfd53..761eb5950 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -168,7 +168,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, - "This operation only supports MD5 content hash"); + "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; @@ -242,7 +242,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.RangeHashAlgorithm.Value() == HashAlgorithm::Md5, - "This operation only supports MD5 content hash"); + "This operation only supports MD5 content hash."); if (options.RangeHashAlgorithm.Value() == HashAlgorithm::Md5) { protocolLayerOptions.GetRangeContentMd5 = true; @@ -272,7 +272,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto newResponse = Download(newOptions, context); if (eTag != newResponse.Value.Details.ETag) { - throw Azure::Core::RequestFailedException("file was modified in the middle of download"); + throw Azure::Core::RequestFailedException("File was modified in the middle of download."); } return std::move(newResponse.Value.BodyStream); }; @@ -350,7 +350,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_ASSERT_MSG(false, "Either FilePermission or FilePermissionKey must be set"); + AZURE_ASSERT_MSG(false, "Either FilePermission or FilePermissionKey must be set."); } } } @@ -489,7 +489,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Md5, - "This operation only supports MD5 content hash"); + "This operation only supports MD5 content hash."); } protocolLayerOptions.ContentMd5 = options.TransactionalContentHash; protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; @@ -691,14 +691,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { if (static_cast(fileRangeSize) > bufferSize) { throw Azure::Core::RequestFailedException( - "buffer is not big enough, file range size is " + std::to_string(fileRangeSize)); + "Buffer is not big enough, file range size is " + std::to_string(fileRangeSize) + "."); } int64_t bytesRead = firstChunk.Value.BodyStream->ReadToCount( buffer, static_cast(firstChunkLength), context); if (bytesRead != firstChunkLength) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } firstChunk.Value.BodyStream.reset(); @@ -726,12 +726,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { context); if (bytesRead != chunkOptions.Range.Value().Length.Value()) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } if (chunk.Value.Details.ETag != etag) { throw Azure::Core::RequestFailedException( - "file was modified in the middle of download"); + "File was modified in the middle of download."); } if (chunkId == numChunks - 1) @@ -812,7 +812,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { size_t bytesRead = stream.ReadToCount(buffer.data(), readSize, context); if (bytesRead != readSize) { - throw Azure::Core::RequestFailedException("error when reading body stream"); + throw Azure::Core::RequestFailedException("Error when reading body stream."); } fileWriter.Write(buffer.data(), bytesRead, offset); length -= bytesRead; @@ -849,7 +849,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { if (chunk.Value.Details.ETag != etag) { throw Azure::Core::RequestFailedException( - "file was modified in the middle of download"); + "File was modified in the middle of download."); } bodyStreamToFile( *(chunk.Value.BodyStream), @@ -946,7 +946,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, - "This operation only supports MD5 content hash"); + "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } protocolLayerOptions.Metadata = options.Metadata; @@ -1050,7 +1050,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, - "This operation only supports MD5 content hash"); + "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; } protocolLayerOptions.Metadata = options.Metadata; @@ -1092,7 +1092,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const UploadFileRangeFromUriOptions& options, const Azure::Core::Context& context) const { - AZURE_ASSERT_MSG(sourceRange.Length.HasValue(), "Source length cannot be null"); + AZURE_ASSERT_MSG(sourceRange.Length.HasValue(), "Source length cannot be null."); int64_t rangeLength = sourceRange.Length.Value(); auto protocolLayerOptions = _detail::ShareRestClient::File::UploadRangeFromUrlOptions(); @@ -1105,7 +1105,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { AZURE_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Crc64, - "This operation only supports CRC64 content hash"); + "This operation only supports CRC64 content hash."); } protocolLayerOptions.SourceContentCrc64 = options.TransactionalContentHash; if (options.SourceAccessCondition.IfMatchContentHash.HasValue()) @@ -1113,7 +1113,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG( options.SourceAccessCondition.IfMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, - "This operation only supports CRC64 Source-If-Match condition"); + "This operation only supports CRC64 Source-If-Match condition."); } protocolLayerOptions.SourceIfMatchCrc64 = options.SourceAccessCondition.IfMatchContentHash; if (options.SourceAccessCondition.IfNoneMatchContentHash.HasValue()) @@ -1121,7 +1121,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { AZURE_ASSERT_MSG( options.SourceAccessCondition.IfNoneMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, - "This operation only supports CRC64 Source-If-None-Match condition"); + "This operation only supports CRC64 Source-If-None-Match condition."); } protocolLayerOptions.SourceIfNoneMatchCrc64 = options.SourceAccessCondition.IfNoneMatchContentHash; diff --git a/sdk/storage/azure-storage-files-shares/src/share_responses.cpp b/sdk/storage/azure-storage-files-shares/src/share_responses.cpp index 2139272fd..af3ef935b 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_responses.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_responses.cpp @@ -50,11 +50,11 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else if (m_status == Azure::Core::OperationStatus::Failed) { - throw Azure::Core::RequestFailedException("Operation failed"); + throw Azure::Core::RequestFailedException("Operation failed."); } else if (m_status == Azure::Core::OperationStatus::Cancelled) { - throw Azure::Core::RequestFailedException("Operation was cancelled"); + throw Azure::Core::RequestFailedException("Operation was cancelled."); } std::this_thread::sleep_for(period); diff --git a/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp b/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp index 8e5e2d795..cc94d4298 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_sas_builder.cpp @@ -21,7 +21,7 @@ namespace Azure { namespace Storage { namespace Sas { } else { - throw std::invalid_argument("unknown ShareSasResource value"); + throw std::invalid_argument("Unknown ShareSasResource value."); } } } // namespace