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..bcf67132 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,10 @@ impl ImpitError { } } } + + if source_error.is_connect() { + return ImpitError::ConnectError(format!("{source_error:#?}")); + } } }