fix(lite): report the preferred server's error on a failed open
The failover overwrote outcome.error on every attempt, so a total open failure reported whichever (often broken) fallback was tried last — e.g. lite5's "CertNotValidForName" — instead of what the user's preferred server actually did. Keep the first (preferred) server's error as the summary so "Open failed: …" names the actionable reason; the per-server attempts are still in the Console log, and the warmup flag is still set if any server was warming up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -356,7 +356,7 @@ bool LiteWalletController::beginOpenExisting()
|
||||
auto resultSlot = openResult_;
|
||||
openThread_ = std::thread([bridge, servers, running, resultMutex, resultSlot]() {
|
||||
OpenOutcome outcome;
|
||||
outcome.error = "could not reach any lite server";
|
||||
std::string preferredError; // error from the FIRST (preferred) server — the actionable one
|
||||
for (const auto& url : servers) {
|
||||
if (!bridge) break;
|
||||
liteLog(" connecting to " + url + " ...");
|
||||
@@ -372,10 +372,14 @@ bool LiteWalletController::beginOpenExisting()
|
||||
const std::string why = call.error.empty() ? "unreachable" : call.error;
|
||||
liteLog(" " + url + ": " + why);
|
||||
if (!call.error.empty()) {
|
||||
outcome.error = call.error;
|
||||
if (preferredError.empty()) preferredError = call.error; // keep the preferred one
|
||||
if (liteOpenErrorIsWarmup(call.error)) outcome.warming = true; // healthy, just starting
|
||||
}
|
||||
}
|
||||
// On total failure, report the preferred server's error (not whichever broken fallback
|
||||
// happened to be tried last), since that's the server the user expects to use.
|
||||
if (!outcome.ok)
|
||||
outcome.error = preferredError.empty() ? "could not reach any lite server" : preferredError;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(*resultMutex);
|
||||
*resultSlot = outcome;
|
||||
|
||||
Reference in New Issue
Block a user