Skip to content

Commit

Permalink
Merge pull request #2465 from HenrikJannsen/Use-ExceptionUtil.getRoot…
Browse files Browse the repository at this point in the history
…CauseMessage-instead-of-getMessageOrToString

Use ExceptionUtil.getRootCauseMessage instead of getMessageOrToString
  • Loading branch information
djing-chan authored Jul 22, 2024
2 parents b5a336d + 9ca6c9d commit 3f30f0e
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand All @@ -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.
Expand Down
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
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 3f30f0e

Please sign in to comment.