Skip to content

Commit

Permalink
treewide: replace query_error -> execution_error
Browse files Browse the repository at this point in the history
  • Loading branch information
muzarski committed Jan 30, 2025
1 parent e391da1 commit 4775c8d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions scylla/src/client/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ where

let (result, paging_state_response) = response
.into_query_result_and_paging_state()
.map_err(RequestAttemptError::into_query_error)?;
.map_err(RequestAttemptError::into_execution_error)?;
span.record_result_fields(&result);

Ok((result, paging_state_response))
Expand Down Expand Up @@ -1319,7 +1319,7 @@ where
let first_ok: Result<PreparedStatement, RequestAttemptError> =
results.by_ref().find_or_first(Result::is_ok).unwrap();
let mut prepared: PreparedStatement =
first_ok.map_err(RequestAttemptError::into_query_error)?;
first_ok.map_err(RequestAttemptError::into_execution_error)?;

// Validate prepared ids equality
for statement in results.flatten() {
Expand Down Expand Up @@ -1407,7 +1407,7 @@ where

let (partition_key, token) = prepared
.extract_partition_key_and_calculate_token(prepared.get_partitioner_name(), values_ref)
.map_err(PartitionKeyError::into_query_error)?
.map_err(PartitionKeyError::into_execution_error)?
.unzip();

let execution_profile = prepared
Expand Down Expand Up @@ -1490,7 +1490,7 @@ where

let (result, paging_state_response) = response
.into_query_result_and_paging_state()
.map_err(RequestAttemptError::into_query_error)?;
.map_err(RequestAttemptError::into_execution_error)?;
span.record_result_fields(&result);

Ok((result, paging_state_response))
Expand Down Expand Up @@ -2006,7 +2006,7 @@ where
}
}

result.map_err(RequestError::into_query_error)
result.map_err(RequestError::into_execution_error)
}

/// Executes the closure `run_request_once`, provided the load balancing plan and some information
Expand Down
16 changes: 8 additions & 8 deletions scylla/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ impl From<SerializationError> for ExecutionError {
}

impl From<ExecutionError> for NewSessionError {
fn from(query_error: ExecutionError) -> NewSessionError {
match query_error {
fn from(execution_error: ExecutionError) -> NewSessionError {
match execution_error {
ExecutionError::DbError(e, msg) => NewSessionError::DbError(e, msg),
ExecutionError::BadQuery(e) => NewSessionError::BadQuery(e),
ExecutionError::CqlRequestSerialization(e) => {
Expand Down Expand Up @@ -943,12 +943,12 @@ pub enum RequestError {
}

impl RequestError {
pub fn into_query_error(self) -> ExecutionError {
pub fn into_execution_error(self) -> ExecutionError {
match self {
RequestError::EmptyPlan => ExecutionError::EmptyPlan,
RequestError::ConnectionPoolError(e) => e.into(),
RequestError::RequestTimeout(dur) => ExecutionError::RequestTimeout(dur),
RequestError::LastAttemptError(e) => e.into_query_error(),
RequestError::LastAttemptError(e) => e.into_execution_error(),
}
}
}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ pub enum RequestAttemptError {

impl RequestAttemptError {
/// Converts the error to [`ExecutionError`].
pub fn into_query_error(self) -> ExecutionError {
pub fn into_execution_error(self) -> ExecutionError {
match self {
RequestAttemptError::CqlRequestSerialization(e) => e.into(),
RequestAttemptError::DbError(err, msg) => ExecutionError::DbError(err, msg),
Expand Down Expand Up @@ -1181,14 +1181,14 @@ mod tests {
assert_eq!(db_error_displayed, expected_dberr_msg);

// Test that ExecutionError::DbError::(DbError::Unavailable) is displayed correctly
let query_error =
let execution_error =
ExecutionError::DbError(db_error, "a message about unavailable error".to_string());
let query_error_displayed: String = format!("{}", query_error);
let execution_error_displayed: String = format!("{}", execution_error);

let mut expected_querr_msg = "Database returned an error: ".to_string();
expected_querr_msg += &expected_dberr_msg;
expected_querr_msg += ", Error message: a message about unavailable error";

assert_eq!(query_error_displayed, expected_querr_msg);
assert_eq!(execution_error_displayed, expected_querr_msg);
}
}
8 changes: 4 additions & 4 deletions scylla/src/network/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ impl Connection {

self.query_raw_unpaged(&query)
.await
.map_err(RequestAttemptError::into_query_error)
.map_err(RequestAttemptError::into_execution_error)
.and_then(QueryResponse::into_query_result)
}

Expand Down Expand Up @@ -893,7 +893,7 @@ impl Connection {
// This method is used only for driver internal queries, so no need to consult execution profile here.
self.execute_raw_unpaged(prepared, values)
.await
.map_err(RequestAttemptError::into_query_error)
.map_err(RequestAttemptError::into_execution_error)
.and_then(QueryResponse::into_query_result)
}

Expand Down Expand Up @@ -1056,7 +1056,7 @@ impl Connection {
batch.config.serial_consistency.flatten(),
)
.await
.map_err(RequestAttemptError::into_query_error)
.map_err(RequestAttemptError::into_execution_error)
.and_then(QueryResponse::into_query_result)
}

Expand Down Expand Up @@ -1190,7 +1190,7 @@ impl Connection {
let query_response = self
.query_raw_unpaged(&query)
.await
.map_err(RequestAttemptError::into_query_error)?;
.map_err(RequestAttemptError::into_execution_error)?;
Self::verify_use_keyspace_result(keyspace_name, query_response)
}

Expand Down
4 changes: 2 additions & 2 deletions scylla/src/response/request_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl QueryResponse {

pub(crate) fn into_query_result(self) -> Result<QueryResult, ExecutionError> {
self.into_non_error_query_response()
.map_err(RequestAttemptError::into_query_error)?
.map_err(RequestAttemptError::into_execution_error)?
.into_query_result()
}
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl NonErrorQueryResponse {
pub(crate) fn into_query_result(self) -> Result<QueryResult, ExecutionError> {
let (result, paging_state) = self
.into_query_result_and_paging_state()
.map_err(RequestAttemptError::into_query_error)?;
.map_err(RequestAttemptError::into_execution_error)?;

if !paging_state.finished() {
error!(
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/statement/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub(crate) mod batch_values {
if did_write {
let token = ps
.calculate_token_untyped(&first_values)
.map_err(PartitionKeyError::into_query_error)?;
.map_err(PartitionKeyError::into_execution_error)?;
(token, Some(first_values))
} else {
(None, None)
Expand Down
2 changes: 1 addition & 1 deletion scylla/src/statement/prepared_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ pub enum PartitionKeyError {

impl PartitionKeyError {
/// Converts the error to [`ExecutionError`].
pub fn into_query_error(self) -> ExecutionError {
pub fn into_execution_error(self) -> ExecutionError {
match self {
PartitionKeyError::PartitionKeyExtraction(_) => {
ExecutionError::ProtocolError(ProtocolError::PartitionKeyExtraction)
Expand Down

0 comments on commit 4775c8d

Please sign in to comment.