From c03138edac0c671f62ac008eb83add9a537eb957 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 15 Apr 2024 14:45:57 -0400 Subject: [PATCH] add default rpc error message when missing --- src/main/java/monero/common/MoneroRpcConnection.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/monero/common/MoneroRpcConnection.java b/src/main/java/monero/common/MoneroRpcConnection.java index d84620ca..bd4808ae 100644 --- a/src/main/java/monero/common/MoneroRpcConnection.java +++ b/src/main/java/monero/common/MoneroRpcConnection.java @@ -609,12 +609,13 @@ private static void validateHttpResponse(CloseableHttpResponse resp) { } @SuppressWarnings("unchecked") - private static void validateRpcResponse(Map respMap, String method, Object params) { + private void validateRpcResponse(Map respMap, String method, Object params) { Map error = (Map) respMap.get("error"); if (error == null) return; - String msg = (String) error.get("message"); + String errorMsg = (String) error.get("message"); int code = ((BigInteger) error.get("code")).intValue(); - throw new MoneroRpcError(msg, code, method, params); + if ("".equals(errorMsg)) errorMsg = "Received error response from RPC request with method '" + method + "' to " + uri; // TODO (monero-project): response sometimes has empty error message + throw new MoneroRpcError(errorMsg, code, method, params); } private RequestConfig getRequestConfig(Long timeoutInMs) {