diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java index 273b9278ab..4032a731a1 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/handlers/JsonRpcExecutorHandler.java @@ -133,14 +133,24 @@ public class JsonRpcExecutorHandler { } else { handleJsonRpcError(ctx, null, JsonRpcError.PARSE_ERROR); } - } catch (IOException ex) { - LOG.error("Error streaming JSON-RPC response", ex); - } catch (RuntimeException e) { + } catch (final IOException ex) { + final String method = getRpcMethodName(ctx); + LOG.error("{} - Error streaming JSON-RPC response", method, ex); + } catch (final RuntimeException e) { handleJsonRpcError(ctx, null, JsonRpcError.INTERNAL_ERROR); } }; } + private static String getRpcMethodName(final RoutingContext ctx) { + if (ctx.data().containsKey(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name())) { + final JsonObject jsonObject = ctx.get(ContextKey.REQUEST_BODY_AS_JSON_OBJECT.name()); + return jsonObject.getString("method"); + } else { + return ""; + } + } + private static void handleJsonRpcError( final RoutingContext routingContext, final Object id, final JsonRpcError error) { final HttpServerResponse response = routingContext.response();