diff --git a/cloud/blockstore/libs/encryption/encryption_client.cpp b/cloud/blockstore/libs/encryption/encryption_client.cpp index 38661d2f70d..5dc5b553c92 100644 --- a/cloud/blockstore/libs/encryption/encryption_client.cpp +++ b/cloud/blockstore/libs/encryption/encryption_client.cpp @@ -22,15 +22,15 @@ namespace { //////////////////////////////////////////////////////////////////////////////// template -TFuture FutureErrorResponse(ui32 code, TString message) +TFuture MakeFutureErrorResponse(ui32 code, TString message) { return MakeFuture(ErrorResponse(code, std::move(message))); } template -TFuture FutureErrorResponse(NProto::TError error) +TFuture MakeFutureErrorResponse(NProto::TError error) { - return FutureErrorResponse( + return MakeFutureErrorResponse( error.GetCode(), std::move(*error.MutableMessage())); } @@ -232,7 +232,7 @@ TFuture TEncryptionClient::MountVolume( { auto& encryption = *request->MutableEncryptionSpec(); if (encryption.GetKeyHash()) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_INVALID_STATE, "More than one encryption layer on data path"); } @@ -279,7 +279,7 @@ TFuture TEncryptionClient::ReadBlocks( std::shared_ptr request) { if (request->GetBlocksCount() == 0 || BlockSize == 0) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_ARGUMENT, "Request size should not be zero"); } @@ -361,7 +361,7 @@ TFuture TEncryptionClient::WriteBlocks( std::shared_ptr request) { if (request->GetBlocks().GetBuffers().size() == 0 || BlockSize == 0) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_ARGUMENT, "Request size should not be zero"); } @@ -386,7 +386,7 @@ TFuture TEncryptionClient::WriteBlocks( request->GetStartIndex()); if (HasError(err)) { - return FutureErrorResponse( + return MakeFutureErrorResponse( std::move(err)); } @@ -403,7 +403,7 @@ TFuture TEncryptionClient::ReadBlocksLocal( std::shared_ptr request) { if (request->GetBlocksCount() == 0 || request->BlockSize == 0) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_ARGUMENT, "Request size should not be zero"); } @@ -504,14 +504,14 @@ TFuture TEncryptionClient::WriteBlocksLocal( std::shared_ptr request) { if (request->BlocksCount == 0 || request->BlockSize == 0) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_ARGUMENT, "Request size should not be zero"); } auto guard = request->Sglist.Acquire(); if (!guard) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_CANCELLED, "failed to acquire sglist in EncryptionClient"); } @@ -549,7 +549,7 @@ TFuture TEncryptionClient::WriteBlocksLocal( request->GetStartIndex()); if (HasError(err)) { - return FutureErrorResponse( + return MakeFutureErrorResponse( std::move(err)); } @@ -578,7 +578,7 @@ TFuture TEncryptionClient::ZeroBlocks( std::shared_ptr request) { if (request->GetBlocksCount() == 0 || BlockSize == 0) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_ARGUMENT, "Request size should not be zero"); } @@ -723,7 +723,7 @@ class TVolumeEncryptionClient final if (request->HasEncryptionSpec() && request->GetEncryptionSpec().GetMode() != NProto::NO_ENCRYPTION) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_INVALID_STATE, "More than one encryption layer on data path"); } @@ -741,7 +741,7 @@ class TVolumeEncryptionClient final auto ptr = weakPtr.lock(); if (!ptr) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_REJECTED, "Encryption client is destroyed after MountVolume"); } @@ -765,13 +765,14 @@ class TVolumeEncryptionClient final { auto [client, error] = f.GetValue(); if (HasError(error)) { - return FutureErrorResponse( - std::move(error)); + return MakeFutureErrorResponse< + NProto::TMountVolumeResponse>(std::move(error)); } auto ptr = weakPtr.lock(); if (!ptr) { - return FutureErrorResponse( + return MakeFutureErrorResponse< + NProto::TMountVolumeResponse>( E_REJECTED, "Encryption client is destroyed after MountVolume"); } @@ -889,7 +890,7 @@ TFuture TSnapshotEncryptionClient::MountVolume( if (encryption.GetKeyHash() && encryption.GetKeyHash() != EncryptionDesc.GetKeyHash()) { - return FutureErrorResponse( + return MakeFutureErrorResponse( E_INVALID_STATE, TStringBuilder() << "Invalid mount encryption key hash" << ", actual " << encryption.GetKeyHash() @@ -985,7 +986,7 @@ TFuture TSnapshotEncryptionClient::ZeroBlocks( Y_UNUSED(callContext); Y_UNUSED(request); - return FutureErrorResponse( + return MakeFutureErrorResponse( E_NOT_IMPLEMENTED, "ZeroBlocks requests not supported by snapshot encryption client"); }