refactor: Use std::expected instead of std::variant for errors (#2160)

This commit is contained in:
Ayaz Salikhov
2025-06-03 13:34:25 +01:00
committed by GitHub
parent 19257f8aa9
commit 550f0fae85
40 changed files with 295 additions and 310 deletions

View File

@@ -55,14 +55,14 @@ LedgerHandler::process(LedgerHandler::Input input, Context const& ctx) const
auto const range = sharedPtrBackend_->fetchLedgerRange();
ASSERT(range.has_value(), "LedgerHandler's ledger range must be available");
auto const lgrInfoOrStatus = getLedgerHeaderFromHashOrSeq(
auto const expectedLgrInfo = getLedgerHeaderFromHashOrSeq(
*sharedPtrBackend_, ctx.yield, input.ledgerHash, input.ledgerIndex, range->maxSequence
);
if (auto const status = std::get_if<Status>(&lgrInfoOrStatus))
return Error{*status};
if (!expectedLgrInfo.has_value())
return Error{expectedLgrInfo.error()};
auto const lgrInfo = std::get<ripple::LedgerHeader>(lgrInfoOrStatus);
auto const& lgrInfo = expectedLgrInfo.value();
Output output;
output.header = toJson(lgrInfo, input.binary, ctx.apiVersion);