From 7a40843ada02e97800fe92c601fd2ceead7de108 Mon Sep 17 00:00:00 2001 From: "S. Matthew English" Date: Fri, 30 Nov 2018 15:11:13 -0500 Subject: [PATCH] [MINOR] Render handler exception to System.err instead of .out (#334) * render error message to System.err instead of .out * log and check exception type * add else * simplification of explanitory comment --- .../ethereum/p2p/discovery/PeerDiscoveryAgent.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java index da07c51177..cc5786d3c1 100644 --- a/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java +++ b/ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/discovery/PeerDiscoveryAgent.java @@ -37,6 +37,7 @@ import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage; import tech.pegasys.pantheon.util.NetworkUtility; import tech.pegasys.pantheon.util.bytes.BytesValue; +import java.io.IOException; import java.net.BindException; import java.net.InetSocketAddress; import java.net.SocketException; @@ -222,12 +223,16 @@ public class PeerDiscoveryAgent implements DisconnectCallback { } /** - * This is the exception handler for uncontrolled exceptions ocurring in the packet handlers. + * For uncontrolled exceptions occurring in the packet handlers. * - * @param throwable the exception that was raised + * @param exception the exception that was raised */ - private void handleException(final Throwable throwable) { - System.out.println(throwable); + private void handleException(final Throwable exception) { + if (exception instanceof IOException) { + LOG.debug("Packet handler exception", exception); + } else { + LOG.error("Packet handler exception", exception); + } } /**