Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion impit-python/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl From<ImpitPyError> 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)),
Expand Down
12 changes: 6 additions & 6 deletions impit/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -107,17 +107,17 @@ impl ImpitError {
.source()
.and_then(|e| e.downcast_ref::<hyper_util::client::legacy::Error>())
{
if source_error.is_connect() {
return ImpitError::ConnectError;
}

if let Some(e) = source_error.source() {
if let Some(hyper_error) = e.downcast_ref::<hyper::Error>() {
if hyper_error.is_incomplete_message() {
return ImpitError::RemoteProtocolError;
}
}
}

if source_error.is_connect() {
return ImpitError::ConnectError(format!("{source_error:#?}"));
}
}
}

Expand Down
Loading