-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Problem
The code pattern for retrieving storage connections from m_storage_factory->provide_storage_connection()
and handling errors is repeated in multiple places throughout the codebase. This leads to code duplication and makes maintenance more difficult.
Current Pattern
std::variant<std::unique_ptr<core::StorageConnection>, core::StorageErr> conn_result
= m_storage_factory->provide_storage_connection();
if (std::holds_alternative<core::StorageErr>(conn_result)) {
throw ConnectionException(std::get<core::StorageErr>(conn_result).description);
}
auto conn = std::move(std::get<std::unique_ptr<core::StorageConnection>>(conn_result));
Proposed Solution
Create a helper method that encapsulates this pattern, potentially something like:
auto try_storage_connection() -> std::unique_ptr<core::StorageConnection>;
This would simplify the calling code and centralize error handling for storage connection retrieval.
Context
This issue was identified during PR review.
References:
Metadata
Metadata
Assignees
Labels
No labels