From 3276307b37f02b9301bb4f1a0371f248b47d4101 Mon Sep 17 00:00:00 2001 From: Ryoji Kurosawa Date: Thu, 12 Oct 2023 16:25:58 +0900 Subject: [PATCH] refactor transaction_id_str() out for future use --- src/jogasaki/utils/abort_error.cpp | 13 ++++++++----- src/jogasaki/utils/abort_error.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/jogasaki/utils/abort_error.cpp b/src/jogasaki/utils/abort_error.cpp index 9b6370a67..d03f77def 100644 --- a/src/jogasaki/utils/abort_error.cpp +++ b/src/jogasaki/utils/abort_error.cpp @@ -81,6 +81,13 @@ void handle_code_and_locator(sharksfin::ErrorCode code, sharksfin::ErrorLocator } } +std::string transaction_id_str(transaction_context& tx) { + if(auto txid = tx.object()->transaction_id(); ! txid.empty()) { + return "transaction:" + std::string{txid} + " "; + } + return {}; +} + std::string create_abort_message( request_context const& rctx ) { @@ -95,11 +102,7 @@ std::string create_abort_message( handle_code_and_locator(result->code(), result->location().get(), *tables, rctx.request_resource(), ss); } } - std::string idstr{}; - if(auto txid = tx.object()->transaction_id(); ! txid.empty()) { - idstr = "transaction:" + std::string{txid} + " "; - } - + auto idstr = transaction_id_str(tx); return string_builder{} << "serialization failed " << idstr << desc << " " << ss.str() << string_builder::to_string; } diff --git a/src/jogasaki/utils/abort_error.h b/src/jogasaki/utils/abort_error.h index 49e5803d0..853dfeac8 100644 --- a/src/jogasaki/utils/abort_error.h +++ b/src/jogasaki/utils/abort_error.h @@ -29,5 +29,7 @@ std::shared_ptr find_storage( std::string_view storage_name ); +std::string transaction_id_str(transaction_context& tx); + }