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