From dcd62143020ba5a38c59a54ea13a0a17d6783418 Mon Sep 17 00:00:00 2001 From: ju4nlu Date: Thu, 22 Feb 2024 14:45:54 +0100 Subject: [PATCH] Improve 'wrong device' error message with expected and actual serial (#16) Co-authored-by: juanlu --- zvt_feig_terminal/src/stream.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zvt_feig_terminal/src/stream.rs b/zvt_feig_terminal/src/stream.rs index 3076fea..d84f4a7 100644 --- a/zvt_feig_terminal/src/stream.rs +++ b/zvt_feig_terminal/src/stream.rs @@ -81,11 +81,13 @@ mod outer { debug!("Received {packet:?}"); match packet? { feig::sequences::GetSystemInfoResponse::CVendFunctionsEnhancedSystemInformationCompletion(packet) => { - if packet.device_id.to_lowercase() == config.feig_serial.to_lowercase() { + let expected_serial: String = config.feig_serial.to_lowercase(); + let actual_serial: String = packet.device_id.to_lowercase(); + if actual_serial == expected_serial { drop(stream); return Ok(socket); } - bail!(Error::new(ErrorKind::NotConnected, "Wrong device")) + bail!(Error::new(ErrorKind::NotConnected, format!("Wrong device. Expected {}, got {}", expected_serial, actual_serial))) }, feig::sequences::GetSystemInfoResponse::Abort(packet) => bail!(zvt::ZVTError::Aborted(packet.error)) }