Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ExceptionUtil.getRootCauseMessage instead of getMessageOrToString #2465

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ public ApplicationService(String configFileName, String[] args) {
try {
typesafeConfig = ConfigFactory.parseFile(customConfigFile).withFallback(defaultTypesafeConfig);
} catch (Exception e) {
System.err.println("Error when reading custom config file " + ExceptionUtil.getMessageOrToString(e));
System.err.println("Error when reading custom config file " + ExceptionUtil.getRootCauseMessage(e));
throw new RuntimeException(e);
}
} else {
Original file line number Diff line number Diff line change
@@ -274,7 +274,7 @@ public CompletableFuture<Boolean> initialize() {
}
} else {
log.error("Initializing applicationService failed", throwable);
startupErrorMessage.set(ExceptionUtil.getMessageOrToString(throwable));
startupErrorMessage.set(ExceptionUtil.getRootCauseMessage(throwable));
}
setState(State.FAILED);
return false;
@@ -309,7 +309,7 @@ public CompletableFuture<Boolean> shutdown() {
.handle((result, throwable) -> {
if (throwable != null) {
log.error("Error at shutdown", throwable);
shutDownErrorMessage.set(ExceptionUtil.getMessageOrToString(throwable));
shutDownErrorMessage.set(ExceptionUtil.getRootCauseMessage(throwable));
return false;
} else if (!result) {
shutDownErrorMessage.set("Shutdown failed with result=false");
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public static void run(Runnable task) {
Platform.runLater(task);
}
} catch (Exception e) {
log.error("Exception at UIThread.run: {}", ExceptionUtil.getMessageOrToString(e));
log.error("Exception at UIThread.run: {}", ExceptionUtil.getRootCauseMessage(e));
throw e;
}
}
Original file line number Diff line number Diff line change
@@ -192,7 +192,7 @@ private void requestTx() {
model.getConfirmationInfo().set(Res.get("bisqEasy.tradeState.info.phase3b.txId.failed",
explorerService.getSelectedProvider().get().getBaseUrl(),
rootCause.getClass().getSimpleName(),
ExceptionUtil.getMessageOrToString(rootCause)));
ExceptionUtil.getRootCauseMessage(rootCause)));
}
});
});
Original file line number Diff line number Diff line change
@@ -192,7 +192,7 @@ private void requestTx() {
model.getConfirmationInfo().set(Res.get("bisqEasy.tradeState.info.phase3b.txId.failed",
explorerService.getSelectedProvider().get().getBaseUrl(),
rootCause.getClass().getSimpleName(),
ExceptionUtil.getMessageOrToString(rootCause)));
ExceptionUtil.getRootCauseMessage(rootCause)));
}
});
});
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ public void onActivate() {
.filter(spec -> spec.getPaymentMethod().getPaymentRail() == persisted).findAny()
.ifPresent(spec -> model.getSelectedBitcoinPaymentMethodSpec().set(spec));
} catch (Exception e) {
log.warn("Could not create BitcoinPaymentRail from persisted name {}. {}", name, ExceptionUtil.getMessageOrToString(e));
log.warn("Could not create BitcoinPaymentRail from persisted name {}. {}", name, ExceptionUtil.getRootCauseMessage(e));
}
});
settingsService.getCookie().asString(CookieKey.TAKE_OFFER_SELECTED_FIAT_METHOD, getCookieSubKey())
@@ -113,7 +113,7 @@ public void onActivate() {
.filter(spec -> spec.getPaymentMethod().getPaymentRail() == persisted).findAny()
.ifPresent(spec -> model.getSelectedFiatPaymentMethodSpec().set(spec));
} catch (Exception e) {
log.warn("Could not create FiatPaymentRail from persisted name {}. {}", name, ExceptionUtil.getMessageOrToString(e));
log.warn("Could not create FiatPaymentRail from persisted name {}. {}", name, ExceptionUtil.getRootCauseMessage(e));
}
});
}
Original file line number Diff line number Diff line change
@@ -70,14 +70,14 @@ public CompletableFuture<Boolean> shutdown() {
return false;
}
} catch (IOException e) {
log.error("Error at shutdown {}", ExceptionUtil.getMessageOrToString(e));
log.error("Error at shutdown {}", ExceptionUtil.getRootCauseMessage(e));
return false;
}
}, ExecutorFactory.newSingleThreadExecutor("ClearNetHttpClient-shutdown"))
.orTimeout(500, TimeUnit.MILLISECONDS)
.whenComplete((result, throwable) -> {
if (throwable != null) {
log.warn("Error at shutdown: {}", ExceptionUtil.getMessageOrToString(throwable));
log.warn("Error at shutdown: {}", ExceptionUtil.getRootCauseMessage(throwable));
}
});
connection = null;
@@ -146,7 +146,7 @@ protected String doRequest(String param, HttpMethod httpMethod, Optional<Pair<St
throw new HttpException("Request failed", responseCode);
}
} catch (Exception e) {
String message = "Request to " + baseUrl + "/" + param + " failed with error: " + ExceptionUtil.getMessageOrToString(e);
String message = "Request to " + baseUrl + "/" + param + " failed with error: " + ExceptionUtil.getRootCauseMessage(e);
throw new IOException(message, e);
} finally {
try {
Original file line number Diff line number Diff line change
@@ -236,7 +236,7 @@ Connection send(EnvelopePayloadMessage envelopePayloadMessage, AuthorizationToke
if (isRunning()) {
throw exception;
} else {
log.info("Send message at stopped connection {} failed with {}", this, ExceptionUtil.getMessageOrToString(exception));
log.info("Send message at stopped connection {} failed with {}", this, ExceptionUtil.getRootCauseMessage(exception));
}
}
}
@@ -253,7 +253,7 @@ Connection send(EnvelopePayloadMessage envelopePayloadMessage, AuthorizationToke
return this;
} catch (IOException exception) {
if (isRunning()) {
log.warn("Send message at {} failed with {}", this, ExceptionUtil.getMessageOrToString(exception));
log.warn("Send message at {} failed with {}", this, ExceptionUtil.getRootCauseMessage(exception));
shutdown(CloseReason.EXCEPTION.exception(exception));
}
// We wrap any exception (also expected EOFException in case of connection close), to leave handling of the exception to the caller.
10 changes: 5 additions & 5 deletions network/network/src/main/java/bisq/network/p2p/node/Node.java
Original file line number Diff line number Diff line change
@@ -411,7 +411,7 @@ private Connection createOutboundConnection(Address address, Capability myCapabi
} catch (ConnectionException e) {
if (e.getCause() != null && e.getReason() != null && e.getReason() == HANDSHAKE_FAILED) {
log.warn("Handshake at creating outbound connection to {} failed. We try again with capability version 0. Error: {}",
address, ExceptionUtil.getMessageOrToString(e));
address, ExceptionUtil.getRootCauseMessage(e));
int version = preferredVersion == 0 ? 1 : 0;
candidate = Capability.withVersion(myCapability, version);
return doCreateOutboundConnection(address, candidate);
@@ -672,7 +672,7 @@ public CompletableFuture<Boolean> shutdown() {
.orTimeout(10, SECONDS)
.whenComplete((list, throwable) -> {
if (throwable != null) {
log.warn("Exception at node shutdown {}", ExceptionUtil.getMessageOrToString(throwable));
log.warn("Exception at node shutdown {}", ExceptionUtil.getRootCauseMessage(throwable));
}
outboundConnectionsByAddress.clear();
inboundConnectionsByAddress.clear();
@@ -746,15 +746,15 @@ private void handleException(Throwable exception) {
}
String msg = "Exception:";
if (exception instanceof EOFException) {
log.info("Exception: {}", ExceptionUtil.getMessageOrToString(exception));
log.info("Exception: {}", ExceptionUtil.getRootCauseMessage(exception));
} else if (exception instanceof ConnectException) {
log.debug(msg, exception);
} else if (exception instanceof SocketException) {
log.debug(msg, exception);
} else if (exception instanceof UnknownHostException) {
log.warn("UnknownHostException. Might happen if we try to connect to wrong network type.", exception);
} else if (exception instanceof SocketTimeoutException) {
log.info("Exception: {}", ExceptionUtil.getMessageOrToString(exception));
log.info("Exception: {}", ExceptionUtil.getRootCauseMessage(exception));
} else if (exception instanceof ConnectionException) {
ConnectionException connectionException = (ConnectionException) exception;
if (connectionException.getCause() instanceof SocketTimeoutException) {
@@ -770,7 +770,7 @@ private void handleException(Throwable exception) {
log.warn(msg, exception);
break;
case PROTOBUF_IS_NULL:
log.info("Exception: {}", ExceptionUtil.getMessageOrToString(exception));
log.info("Exception: {}", ExceptionUtil.getRootCauseMessage(exception));
break;
case AUTHORIZATION_FAILED:
log.warn(msg, exception);
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ private void requestInventoryFromFreshConnection(Connection connection) {
.whenComplete((inventory, throwable) -> {
if (throwable != null) {
log.error("Exception at inventory request to peer {}: {}",
connection.getPeerAddress().getFullAddress(), ExceptionUtil.getMessageOrToString(throwable));
connection.getPeerAddress().getFullAddress(), ExceptionUtil.getRootCauseMessage(throwable));
} else {
if (!allDataReceived.get()) {
if (inventory.allDataReceived()) {
@@ -196,7 +196,7 @@ private void startPeriodicRequests(long interval) {
.whenComplete((inventory, throwable) -> {
if (throwable != null) {
log.info("Exception at periodic inventory request to peer {}: {}",
connection.getPeerAddress().getFullAddress(), ExceptionUtil.getMessageOrToString(throwable));
connection.getPeerAddress().getFullAddress(), ExceptionUtil.getRootCauseMessage(throwable));
} else if (inventory.allDataReceived()) {
allDataReceived.set(true);
}
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ private void handleInventoryRequest(InventoryRequest request, Connection connect
System.currentTimeMillis() - ts);
} catch (Exception e) {
log.warn("Error at sending InventoryResponse to {}. {}", connection.getPeerAddress(),
ExceptionUtil.getMessageOrToString(e));
ExceptionUtil.getRootCauseMessage(e));
}
});
} else {