From 545efbb36e191eb69b46686624544c6bb51dc9d6 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Thu, 16 Feb 2023 16:49:05 +0100 Subject: [PATCH] logs: improve broken handshake info Signed-off-by: ljedrz --- node/router/src/handshake.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 70d5f243bf..8aee4a4cdb 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -58,7 +58,18 @@ macro_rules! expect_message { return Err(error(format!("'{}' disconnected: {reason:?}", $peer_addr))) } // Received an unexpected message, abort. - _ => return Err(error(format!("'{}' did not follow the handshake protocol", $peer_addr))), + Some(ty) => { + return Err(error(format!( + "'{}' did not follow the handshake protocol: received {:?} instead of {}", + $peer_addr, + ty.name(), + stringify!($msg_ty), + ))) + } + // Received nothing. + None => { + return Err(error(format!("'{}' disconnected before sending {:?}", $peer_addr, stringify!($msg_ty),))) + } } }; }