log stack trace for unexpected polling errors

This commit is contained in:
woodser 2025-11-16 13:35:49 -05:00
parent bb2704c390
commit a09c3a2079
No known key found for this signature in database
GPG key ID: 55A10DD48ADEE5EF
3 changed files with 14 additions and 6 deletions

View file

@ -3319,10 +3319,10 @@ public abstract class Trade extends XmrWalletBase implements Tradable, Model {
} else {
boolean isWalletConnected = isWalletConnectedToDaemon();
if (wallet != null && !isShutDownStarted && isWalletConnected) {
if (e instanceof NullPointerException) {
log.warn("Error polling trade wallet for {} {}, errorMessage={}. Monerod={}", getClass().getSimpleName(), getShortId(), e.getMessage(), wallet.getDaemonConnection(), e);
} else {
if (isExpectedWalletError(e)) {
log.warn("Error polling trade wallet for {} {}, errorMessage={}. Monerod={}", getClass().getSimpleName(), getShortId(), e.getMessage(), wallet.getDaemonConnection());
} else {
log.warn("Error polling trade wallet for {} {}, errorMessage={}. Monerod={}", getClass().getSimpleName(), getShortId(), e.getMessage(), wallet.getDaemonConnection(), e); // include stack trace for unexpected errors
}
}
}

View file

@ -36,6 +36,7 @@ public abstract class XmrWalletBase {
// constants
private static final int SYNC_TIMEOUT_SECONDS = 180;
private static final String SYNC_TIMEOUT_MSG = "Sync timeout called";
private static final String RECEIVED_ERROR_RESPONSE_MSG = "Received error response from RPC request";
private static final long SAVE_AFTER_ELAPSED_SECONDS = 300;
private Object saveIntervalLock = new Object();
protected long lastSaveTimeMs = 0;
@ -96,7 +97,7 @@ public abstract class XmrWalletBase {
future.cancel(true);
throw new RuntimeException(SYNC_TIMEOUT_MSG, e);
} catch (ExecutionException e) {
throw new RuntimeException("Sync failed", e.getCause());
throw new RuntimeException("Sync failed", e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // restore interrupt status
throw new RuntimeException("Sync was interrupted", e);
@ -281,4 +282,8 @@ public abstract class XmrWalletBase {
// update state
wasWalletSynced = true;
}
protected boolean isExpectedWalletError(Exception e) {
return e.getMessage() != null && e.getMessage().contains(RECEIVED_ERROR_RESPONSE_MSG); // TODO: why does this error happen "normally"?
}
}

View file

@ -2050,8 +2050,11 @@ public class XmrWalletService extends XmrWalletBase {
if (wallet == null || isShutDownStarted) return;
if (HavenoUtils.isUnresponsive(e)) forceRestartMainWallet();
else if (isWalletConnectedToDaemon()) {
log.warn("Error polling main wallet, errorMessage={}. Monerod={}", e.getMessage(), getXmrConnectionService().getConnection());
//e.printStackTrace();
if (isExpectedWalletError(e)) {
log.warn("Error polling main wallet, errorMessage={}. Monerod={}", e.getMessage(), getXmrConnectionService().getConnection());
} else {
log.warn("Error polling main wallet, errorMessage={}. Monerod={}", e.getMessage(), getXmrConnectionService().getConnection(), e); // include stack trace for unexpected errors
}
}
} finally {
if (pollInProgressSet) {