Skip to content

Commit

Permalink
refactor transaction_id_str() out for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
kuron99 committed Oct 12, 2023
1 parent 56007e3 commit 3276307
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/jogasaki/utils/abort_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/jogasaki/utils/abort_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ std::shared_ptr<yugawara::storage::index const> find_storage(
std::string_view storage_name
);

std::string transaction_id_str(transaction_context& tx);

}

0 comments on commit 3276307

Please sign in to comment.