From 0363aff71a886b112c704c7e426025cc9c0ed4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Wed, 3 Sep 2025 15:02:44 +0200 Subject: [PATCH 1/3] feat: include error message in `ConnectError` --- impit-python/src/errors.rs | 4 +++- impit/src/errors.rs | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/impit-python/src/errors.rs b/impit-python/src/errors.rs index c9b49abd..010e452c 100644 --- a/impit-python/src/errors.rs +++ b/impit-python/src/errors.rs @@ -56,7 +56,9 @@ impl From for pyo3::PyErr { ImpitPyError(ImpitError::WriteTimeout) => WriteTimeout::new_err(format!("{}", err.0)), ImpitPyError(ImpitError::PoolTimeout) => PoolTimeout::new_err(format!("{}", err.0)), ImpitPyError(ImpitError::NetworkError) => NetworkError::new_err(format!("{}", err.0)), - ImpitPyError(ImpitError::ConnectError) => ConnectError::new_err(format!("{}", err.0)), + ImpitPyError(ImpitError::ConnectError(_)) => { + ConnectError::new_err(format!("{}", err.0)) + } ImpitPyError(ImpitError::ReadError) => ReadError::new_err(format!("{}", err.0)), ImpitPyError(ImpitError::WriteError) => WriteError::new_err(format!("{}", err.0)), ImpitPyError(ImpitError::CloseError) => CloseError::new_err(format!("{}", err.0)), diff --git a/impit/src/errors.rs b/impit/src/errors.rs index 74c70ee8..b961bf87 100644 --- a/impit/src/errors.rs +++ b/impit/src/errors.rs @@ -34,8 +34,8 @@ pub enum ImpitError { PoolTimeout, #[error("Network error occurred.")] NetworkError, - #[error("Failed to connect to the server.")] - ConnectError, + #[error("Failed to connect to the server.\nReason: {0}")] + ConnectError(String), #[error("Failed to read data from the server.")] ReadError, #[error("Failed to write data to the server.")] @@ -107,10 +107,6 @@ impl ImpitError { .source() .and_then(|e| e.downcast_ref::()) { - if source_error.is_connect() { - return ImpitError::ConnectError; - } - if let Some(e) = source_error.source() { if let Some(hyper_error) = e.downcast_ref::() { if hyper_error.is_incomplete_message() { @@ -118,6 +114,18 @@ impl ImpitError { } } } + + println!("{source_error:#?}"); + + if format!("{source_error:#?}").contains("Tunnel") { + return ImpitError::ProxyError(String::from( + "Connection to the proxy server failed.", + )); + } + + if source_error.is_connect() { + return ImpitError::ConnectError(format!("{source_error:#?}")); + } } } From 6041e0bff28f854c83b1d5f4dac1c6b7a6690983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Wed, 3 Sep 2025 15:07:43 +0200 Subject: [PATCH 2/3] chore: remove stray debugging print --- impit/src/errors.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/impit/src/errors.rs b/impit/src/errors.rs index b961bf87..85ec55c5 100644 --- a/impit/src/errors.rs +++ b/impit/src/errors.rs @@ -115,8 +115,6 @@ impl ImpitError { } } - println!("{source_error:#?}"); - if format!("{source_error:#?}").contains("Tunnel") { return ImpitError::ProxyError(String::from( "Connection to the proxy server failed.", From b0b61532df1a5f4afaa433872173332942cd43d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Wed, 3 Sep 2025 15:08:34 +0200 Subject: [PATCH 3/3] chore: revert `ProxyError`-related changes --- impit/src/errors.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/impit/src/errors.rs b/impit/src/errors.rs index 85ec55c5..bcf67132 100644 --- a/impit/src/errors.rs +++ b/impit/src/errors.rs @@ -115,12 +115,6 @@ impl ImpitError { } } - if format!("{source_error:#?}").contains("Tunnel") { - return ImpitError::ProxyError(String::from( - "Connection to the proxy server failed.", - )); - } - if source_error.is_connect() { return ImpitError::ConnectError(format!("{source_error:#?}")); }