Catch as const whenever possible (#2361)

Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
Anton Kolesnyk 2021-05-28 08:52:59 +00:00 committed by GitHub
parent 78703658a2
commit a742608406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 17 additions and 17 deletions

View File

@ -130,7 +130,7 @@ FileBodyStream::FileBodyStream(const std::string& filename)
m_randomAccessFileBodyStream = std::make_unique<_internal::RandomAccessFileBodyStream>(
_internal::RandomAccessFileBodyStream(m_filehandle, 0, fileSize.QuadPart));
}
catch (std::exception&)
catch (const std::exception&)
{
if (fileHandle != INVALID_HANDLE_VALUE)
{
@ -156,7 +156,7 @@ FileBodyStream::FileBodyStream(const std::string& filename)
m_randomAccessFileBodyStream = std::make_unique<_internal::RandomAccessFileBodyStream>(
_internal::RandomAccessFileBodyStream(m_fileDescriptor, 0, fileSize));
}
catch (std::exception&)
catch (const std::exception&)
{
close(m_fileDescriptor);
throw;

View File

@ -482,12 +482,12 @@ namespace Azure { namespace Core { namespace Test {
{
auto result = m_pipeline->Send(request, Azure::Core::Context::ApplicationContext);
}
catch (Azure::Core::RequestFailedException& err)
catch (const Azure::Core::RequestFailedException& err)
{
// if ref can't be cast, it throws
EXPECT_NO_THROW((void)dynamic_cast<Azure::Core::Http::TransportException&>(err));
EXPECT_NO_THROW((void)dynamic_cast<std::runtime_error&>(err));
EXPECT_THROW((void)dynamic_cast<std::range_error&>(err), std::bad_cast);
EXPECT_NO_THROW((void)dynamic_cast<const Azure::Core::Http::TransportException&>(err));
EXPECT_NO_THROW((void)dynamic_cast<const std::runtime_error&>(err));
EXPECT_THROW((void)dynamic_cast<const std::range_error&>(err), std::bad_cast);
}
}

View File

@ -771,7 +771,7 @@ try
{
return this->options.at(name);
}
catch (std::out_of_range const& e)
catch (const std::out_of_range const& e)
{
std::ostringstream msg;
msg << "no option named \"" << name << "\" in parser_results." << e.what();

View File

@ -57,7 +57,7 @@ void BlobSas()
// Never reach here
std::abort();
}
catch (Azure::Storage::StorageException&)
catch (const Azure::Storage::StorageException&)
{
}
}

View File

@ -94,7 +94,7 @@ namespace Azure { namespace Storage { namespace Test {
{
blobClient0.Delete();
}
catch (StorageException&)
catch (const StorageException&)
{
}
auto blobClient = Blobs::AppendBlobClient(blobUrl + sas);

View File

@ -395,7 +395,7 @@ namespace Azure { namespace Storage { namespace Test {
deletedContainerItem.Name, deletedContainerItem.VersionId.Value());
break;
}
catch (StorageException& e)
catch (const StorageException& e)
{
if (e.StatusCode == Azure::Core::Http::HttpStatusCode::Conflict
&& e.ReasonPhrase == "The specified container is being deleted.")

View File

@ -897,7 +897,7 @@ namespace Azure { namespace Storage { namespace Test {
{
blockBlobClient.Download();
}
catch (StorageException& e)
catch (const StorageException& e)
{
exceptionCaught = true;
EXPECT_EQ(e.StatusCode, Azure::Core::Http::HttpStatusCode::NotFound);

View File

@ -41,7 +41,7 @@ namespace Azure { namespace Storage { namespace _internal {
{
transferFunc(chunkOffset, chunkLength, chunkId, numChunks);
}
catch (std::exception&)
catch (const std::exception&)
{
if (failed.exchange(true) == false)
{

View File

@ -33,7 +33,7 @@ void DataLakeGettingStarted()
{
fileSystemClient.Create();
}
catch (Azure::Storage::StorageException& e)
catch (const Azure::Storage::StorageException& e)
{
if (e.ErrorCode != "ContainerAlreadyExists")
{

View File

@ -105,7 +105,7 @@ namespace Azure { namespace Storage { namespace Test {
{
fileClient0.Delete();
}
catch (StorageException&)
catch (const StorageException&)
{
}
auto fileClient = Files::DataLake::DataLakeFileClient(fileUrl + sas);
@ -117,7 +117,7 @@ namespace Azure { namespace Storage { namespace Test {
{
fileClient0.Delete();
}
catch (StorageException&)
catch (const StorageException&)
{
}
std::string newFilename = RandomString();

View File

@ -21,7 +21,7 @@ void FileShareGettingStarted()
{
shareClient.Create();
}
catch (std::runtime_error& e)
catch (const std::runtime_error& e)
{
// The share may already exist
std::cout << e.what() << std::endl;

View File

@ -824,7 +824,7 @@ namespace Azure { namespace Storage { namespace Test {
{
fileClient.Create(1024);
}
catch (StorageException& e)
catch (const StorageException& e)
{
EXPECT_NE(e.StatusCode, Azure::Core::Http::HttpStatusCode::None);
EXPECT_FALSE(e.ReasonPhrase.empty());