Skip to content

Commit e0daa04

Browse files
Added try catch to UnlockFile (#10)
1 parent 7c9a342 commit e0daa04

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/AVEVA/RocksDB/Plugin/Azure/BlobFilesystem.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,17 +568,34 @@ namespace AVEVA::RocksDB::Plugin::Azure
568568
const rocksdb::IOOptions&,
569569
rocksdb::IODebugContext*)
570570
{
571-
auto lockFile = dynamic_cast<Plugin::Azure::LockFile*>(l);
572-
if (lockFile != nullptr)
571+
try
573572
{
574-
lockFile->Unlock();
575-
delete lockFile;
576-
return rocksdb::IOStatus::OK();
573+
auto lockFile = dynamic_cast<Plugin::Azure::LockFile*>(l);
574+
if (lockFile != nullptr)
575+
{
576+
lockFile->Unlock();
577+
delete lockFile;
578+
return rocksdb::IOStatus::OK();
579+
}
580+
else
581+
{
582+
BOOST_LOG_SEV(*m_logger, error) << "Unable to case file lock to Azure::LockFile";
583+
return rocksdb::IOStatus::InvalidArgument();
584+
}
577585
}
578-
else
586+
catch (const ::Azure::Core::RequestFailedException& ex)
587+
{
588+
BOOST_LOG_SEV(*m_logger, error) << "[" << ex.ErrorCode << "]" << " (Status Code: " << static_cast<int>(ex.StatusCode) << ") " << ex.Message;
589+
return AzureErrorTranslator::IOStatusFromError(ex.Message, ex.StatusCode);
590+
}
591+
catch (const std::exception& ex)
592+
{
593+
BOOST_LOG_SEV(*m_logger, error) << ex.what();
594+
return rocksdb::IOStatus::IOError(ex.what());
595+
}
596+
catch (...)
579597
{
580-
BOOST_LOG_SEV(*m_logger, error) << "Unable to case file lock to Azure::LockFile";
581-
return rocksdb::IOStatus::InvalidArgument();
598+
return rocksdb::IOStatus::IOError("Unknown error when calling UnlockFile");
582599
}
583600
}
584601

0 commit comments

Comments
 (0)