Skip to content

Commit

Permalink
conn: map sub-error type to UserRequestError
Browse files Browse the repository at this point in the history
Ultimately, we want to get rid of From<RequestError> for QueryError
implementation. This is because, RequestError contains a
CqlResponseParseError which is overloaded with variants such
as CqlAuthChallengeParseError which should not be returned to the user
who uses only BATCH, QUERY, EXECUTE and PREPARE requests.

This is why, we make two transitions in error types in this place.
The first transition is RequestError -> UserRequestError (map_err()),
which filters out variants such as CqlAuthChallengeParseError, and leaves
only either CqlErrorParseError or CqlResultParseError.
The second transition (? operator) is UserRequestError -> QueryError
which makes use of From<UserRequestError> for QueryError implementation.
  • Loading branch information
muzarski committed Aug 26, 2024
1 parent e07cb33 commit 90c2d16
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scylla/src/transport/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,8 @@ impl Connection {
loop {
let query_response = self
.send_request(&batch_frame, true, batch.config.tracing, None)
.await?;
.await
.map_err(UserRequestError::from)?;

return match query_response.response {
Response::Error(err) => match err.error {
Expand Down

0 comments on commit 90c2d16

Please sign in to comment.