set or clear connection error message on each daemon poll

This commit is contained in:
woodser 2023-11-16 09:02:38 -05:00
parent 0bc5300a27
commit 83352ec1e3

View File

@ -566,13 +566,17 @@ public final class CoreMoneroConnectionsService {
if (lastErrorTimestamp != null) { if (lastErrorTimestamp != null) {
log.info("Successfully fetched daemon info after previous error"); log.info("Successfully fetched daemon info after previous error");
lastErrorTimestamp = null; lastErrorTimestamp = null;
if (HavenoUtils.havenoSetup != null) HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(null);
} }
// update and notify connected state // update and notify connected state
if (!Boolean.TRUE.equals(connectionManager.isConnected())) { if (!Boolean.TRUE.equals(connectionManager.isConnected())) {
connectionManager.checkConnection(); connectionManager.checkConnection();
} }
// clear error message
if (Boolean.TRUE.equals(connectionManager.isConnected()) && HavenoUtils.havenoSetup != null) {
HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(null);
}
} catch (Exception e) { } catch (Exception e) {
// log error message periodically // log error message periodically
@ -582,14 +586,16 @@ public final class CoreMoneroConnectionsService {
if (DevEnv.isDevMode()) e.printStackTrace(); if (DevEnv.isDevMode()) e.printStackTrace();
} }
// notify error message
if (HavenoUtils.havenoSetup != null) HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage());
// check connection which notifies of changes // check connection which notifies of changes
synchronized (this) { synchronized (this) {
if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection()); if (connectionManager.getAutoSwitch()) connectionManager.setConnection(connectionManager.getBestAvailableConnection());
else connectionManager.checkConnection(); else connectionManager.checkConnection();
} }
// set error message
if (!Boolean.TRUE.equals(connectionManager.isConnected()) && HavenoUtils.havenoSetup != null) {
HavenoUtils.havenoSetup.getWalletServiceErrorMsg().set(e.getMessage());
}
} }
} }