From ea49ba396dd4bdc922a44639876b7b1b7e0aa5f7 Mon Sep 17 00:00:00 2001 From: funtimes909 Date: Wed, 21 May 2025 00:19:22 +1200 Subject: [PATCH] Better error handling for networking code --- src/ping.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ping.rs b/src/ping.rs index 92eb935..1cc823d 100644 --- a/src/ping.rs +++ b/src/ping.rs @@ -32,7 +32,7 @@ pub async fn ping_server((address, port): (&str, u16)) -> Result Result Result 32767 { - debug!( - "Received abnormally large string length from {}: {}", - address, string_length - ); + debug!("[{address}] Received abnormally large string length: {string_length}"); } // WARNING: Don't allocate vec size based on what the server says it needs from the varint. @@ -67,7 +64,7 @@ pub async fn ping_server((address, port): (&str, u16)) -> Result total_read_bytes { - debug!("Index: {index} is bigger than total read bytes: {total_read_bytes}"); + debug!("[{address}] Index: {index} is bigger than total read bytes: {total_read_bytes}"); return Err(RunError::MalformedResponse); } @@ -76,7 +73,7 @@ pub async fn ping_server((address, port): (&str, u16)) -> Result string_length { debug!( - "Total read bytes: {total_read_bytes} is larger than string length: {string_length}" + "[{address}] Total read bytes: {total_read_bytes} is larger than string length: {string_length}" ); return Err(RunError::MalformedResponse); }