Skip to content

Commit

Permalink
refactor: return an error in case response deserialization fails
Browse files Browse the repository at this point in the history
  • Loading branch information
uriel-starkware committed Jul 7, 2024
1 parent fb92713 commit 0fa3cf6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/mempool_infra/src/component_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where
let body_bytes = to_bytes(http_response.into_body())
.await
.map_err(ClientError::ResponseParsingFailure)?;
Ok(deserialize(&body_bytes).expect("Response deserialization should succeed"))
deserialize(&body_bytes).map_err(|_e| ClientError::ResponseDeserializationFailure)
}
}

Expand Down Expand Up @@ -122,6 +122,8 @@ pub enum ClientError {
ResponseParsingFailure(HyperError),
#[error("Got an unexpected response type.")]
UnexpectedResponse,
#[error("Could not deserialize response from server.")]
ResponseDeserializationFailure,
}

pub type ClientResult<T> = Result<T, ClientError>;

0 comments on commit 0fa3cf6

Please sign in to comment.