Improve logging

This commit is contained in:
Manfred Karrer 2019-01-02 00:05:14 +01:00
parent 0dadc05233
commit 4c3a721535
No known key found for this signature in database
GPG Key ID: 401250966A6B2C46

View File

@ -21,6 +21,8 @@ import bisq.core.dao.node.BsqNode;
import bisq.core.dao.node.explorer.ExportJsonFilesService;
import bisq.core.dao.node.full.network.FullNodeNetworkService;
import bisq.core.dao.node.parser.BlockParser;
import bisq.core.dao.node.parser.exceptions.BlockHashNotConnectingException;
import bisq.core.dao.node.parser.exceptions.BlockHeightNotConnectingException;
import bisq.core.dao.node.parser.exceptions.RequiredReorgFromSnapshotException;
import bisq.core.dao.state.DaoStateService;
import bisq.core.dao.state.DaoStateSnapshotService;
@ -239,32 +241,36 @@ public class FullNode extends BsqNode {
}
private void handleError(Throwable throwable) {
String errorMessage = "An error occurred: Error=" + throwable.toString();
log.error(errorMessage);
throwable.printStackTrace();
if (throwable instanceof BlockHashNotConnectingException || throwable instanceof BlockHeightNotConnectingException) {
log.warn(throwable.toString());
} else {
String errorMessage = "An error occurred: Error=" + throwable.toString();
log.error(errorMessage);
throwable.printStackTrace();
if (throwable instanceof RpcException) {
Throwable cause = throwable.getCause();
if (cause != null) {
if (cause instanceof HttpLayerException) {
if (((HttpLayerException) cause).getCode() == 1004004) {
if (warnMessageHandler != null)
warnMessageHandler.accept("You have configured Bisq to run as DAO full node but there is no " +
"localhost Bitcoin Core node detected. You need to have Bitcoin Core started and synced before " +
"starting Bisq. Please restart Bisq with proper DAO full node setup or switch to lite node mode.");
if (throwable instanceof RpcException) {
Throwable cause = throwable.getCause();
if (cause != null) {
if (cause instanceof HttpLayerException) {
if (((HttpLayerException) cause).getCode() == 1004004) {
if (warnMessageHandler != null)
warnMessageHandler.accept("You have configured Bisq to run as DAO full node but there is no " +
"localhost Bitcoin Core node detected. You need to have Bitcoin Core started and synced before " +
"starting Bisq. Please restart Bisq with proper DAO full node setup or switch to lite node mode.");
return;
}
} else if (cause instanceof NotificationHandlerException) {
// Maybe we need to react specifically to errors as in NotificationHandlerException.getError()
// So far only IO_UNKNOWN was observed
log.error("Error type of NotificationHandlerException: " + ((NotificationHandlerException) cause).getError().toString());
startReOrgFromLastSnapshot();
return;
}
} else if (cause instanceof NotificationHandlerException) {
// Maybe we need to react specifically to errors as in NotificationHandlerException.getError()
// So far only IO_UNKNOWN was observed
log.error("Error type of NotificationHandlerException: " + ((NotificationHandlerException) cause).getError().toString());
startReOrgFromLastSnapshot();
return;
}
}
}
if (errorMessageHandler != null)
errorMessageHandler.accept(errorMessage);
if (errorMessageHandler != null)
errorMessageHandler.accept(errorMessage);
}
}
}