Skip to content

Commit

Permalink
JavaRpcClientJavaNet: log network errors with .warn()
Browse files Browse the repository at this point in the history
These errors are generally handled by higher-layer software and it
is excessively verbose to log them at ERROR level at this layer.
  • Loading branch information
msgilligan committed Sep 22, 2023
1 parent 6b01074 commit 8df09bb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private CompletableFuture<String> sendCommon(JsonRpcRequest request) {
private CompletableFuture<HttpResponse<String>> handleStatusError(HttpResponse<String> response) {
if (response.statusCode() != 200) {
String errorResponse = response.body();
log.error("Bad status code: {}: {}", response.statusCode(), errorResponse);
log.warn("Bad status code: {}: {}", response.statusCode(), errorResponse);
// TODO: If the error Response is JSON (which it is for method not found, at least) it shouldn't be the "message" in the exception
return CompletableFuture.failedFuture(new JsonRpcStatusException(errorResponse, response.statusCode(), errorResponse, -1, errorResponse, null));

Expand Down Expand Up @@ -165,15 +165,15 @@ private void log(HttpResponse<String> httpResponse, Throwable t) {
if ((httpResponse != null)) {
log.info("log data string: {}", httpResponse);
} else {
log.error("exception: ", t);
log.warn("exception: ", t);
}
}

private void log(String s, Throwable t) {
if ((s != null)) {
log.info("log data string: {}", s.substring(0 ,Math.min(100, s.length())));
} else {
log.error("exception: ", t);
log.warn("exception: ", t);
}
}
}

0 comments on commit 8df09bb

Please sign in to comment.