Skip to content

Commit 0720d4b

Browse files
committed
errors: move errors module to transport module
Originally, all errors could be found under scylla::transport::errors. Let's retain the same path.
1 parent 8a57b68 commit 0720d4b

27 files changed

+37
-35
lines changed

examples/schema_agreement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{bail, Result};
22
use futures::TryStreamExt;
3-
use scylla::errors::QueryError;
3+
use scylla::transport::errors::QueryError;
44
use scylla::transport::session::Session;
55
use scylla::SessionBuilder;
66
use std::env;

examples/tower.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ struct SessionService {
1313
// A trivial service implementation for sending parameterless simple string requests to Scylla.
1414
impl Service<scylla::query::Query> for SessionService {
1515
type Response = scylla::QueryResult;
16-
type Error = scylla::errors::QueryError;
16+
type Error = scylla::transport::errors::QueryError;
1717
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
1818

1919
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {

scylla/src/history.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
time::SystemTime,
88
};
99

10-
use crate::{errors::QueryError, retry_policy::RetryDecision};
10+
use crate::{retry_policy::RetryDecision, transport::errors::QueryError};
1111
use chrono::{DateTime, Utc};
1212

1313
use tracing::warn;
@@ -455,10 +455,10 @@ mod tests {
455455
};
456456

457457
use crate::{
458-
errors::{DbError, QueryError},
459458
query::Query,
460459
retry_policy::RetryDecision,
461460
test_utils::setup_tracing,
461+
transport::errors::{DbError, QueryError},
462462
utils::test_utils::unique_keyspace_name,
463463
};
464464

scylla/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ pub mod authentication;
170170
#[cfg(feature = "cloud")]
171171
pub mod cloud;
172172

173-
pub mod errors;
174173
pub mod history;
175174
pub mod routing;
176175
pub mod statement;

scylla/src/statement/batch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ pub(crate) mod batch_values {
216216
use scylla_cql::types::serialize::row::SerializedValues;
217217
use scylla_cql::types::serialize::{RowWriter, SerializationError};
218218

219-
use crate::errors::QueryError;
220219
use crate::routing::Token;
220+
use crate::transport::errors::QueryError;
221221

222222
use super::BatchStatement;
223223

scylla/src/statement/prepared_statement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ use thiserror::Error;
1313
use uuid::Uuid;
1414

1515
use super::{PageSize, StatementConfig};
16-
use crate::errors::{BadQuery, QueryError};
1716
use crate::frame::response::result::PreparedMetadata;
1817
use crate::frame::types::{Consistency, SerialConsistency};
1918
use crate::history::HistoryListener;
2019
use crate::retry_policy::RetryPolicy;
2120
use crate::routing::Token;
21+
use crate::transport::errors::{BadQuery, QueryError};
2222
use crate::transport::execution_profile::ExecutionProfileHandle;
2323
use crate::transport::partitioner::{Partitioner, PartitionerHasher, PartitionerName};
2424

scylla/src/transport/caching_session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::batch::{Batch, BatchStatement};
2-
use crate::errors::QueryError;
32
use crate::prepared_statement::PreparedStatement;
43
use crate::query::Query;
54
use crate::statement::{PagingState, PagingStateResponse};
5+
use crate::transport::errors::QueryError;
66
use crate::transport::iterator::RowIterator;
77
use crate::transport::partitioner::PartitionerName;
88
use crate::{QueryResult, Session};

scylla/src/transport/cluster.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::errors::{BadQuery, NewSessionError, QueryError};
21
/// Cluster manages up to date information and connections to database nodes
32
use crate::frame::response::event::{Event, StatusChangeEvent};
43
use crate::prepared_statement::TokenCalculationError;
54
use crate::routing::{Shard, Token};
5+
use crate::transport::errors::{BadQuery, NewSessionError, QueryError};
66
use crate::transport::host_filter::HostFilter;
77
use crate::transport::session::TABLET_CHANNEL_SIZE;
88
use crate::transport::{

scylla/src/transport/connection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use tokio_openssl::SslStream;
3030
pub(crate) use ssl_config::SslConfig;
3131

3232
use crate::authentication::AuthenticatorProvider;
33-
use crate::errors::{
33+
use crate::transport::errors::{
3434
BadKeyspaceName, BrokenConnectionError, BrokenConnectionErrorKind, ConnectionError,
3535
ConnectionSetupRequestError, ConnectionSetupRequestErrorKind, CqlEventHandlingError, DbError,
3636
QueryError, RequestError, ResponseParseError, TranslationError, UserRequestError,
@@ -2709,7 +2709,7 @@ mod tests {
27092709
#[ntest::timeout(20000)]
27102710
#[cfg(not(scylla_cloud_tests))]
27112711
async fn connection_is_closed_on_no_response_to_keepalives() {
2712-
use crate::errors::BrokenConnectionErrorKind;
2712+
use crate::transport::errors::BrokenConnectionErrorKind;
27132713

27142714
setup_tracing();
27152715

scylla/src/transport/connection_pool.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#[cfg(feature = "cloud")]
22
use crate::cloud::set_ssl_config_for_scylla_cloud_host;
33

4-
use crate::errors::{BrokenConnectionErrorKind, ConnectionError, ConnectionPoolError, QueryError};
54
use crate::routing::{Shard, ShardCount, Sharder};
5+
use crate::transport::errors::{
6+
BrokenConnectionErrorKind, ConnectionError, ConnectionPoolError, QueryError,
7+
};
68
use crate::transport::{
79
connection,
810
connection::{Connection, ConnectionConfig, ErrorReceiver, VerifiedKeyspaceName},

scylla/src/transport/downgrading_consistency_retry_policy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use scylla_cql::Consistency;
22
use tracing::debug;
33

44
use crate::{
5-
errors::{DbError, QueryError, WriteType},
65
retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession},
6+
transport::errors::{DbError, QueryError, WriteType},
77
};
88

99
/// Downgrading consistency retry policy - retries with lower consistency level if it knows\
@@ -185,8 +185,8 @@ mod tests {
185185

186186
use bytes::Bytes;
187187

188-
use crate::errors::BadQuery;
189188
use crate::test_utils::setup_tracing;
189+
use crate::transport::errors::BadQuery;
190190

191191
use super::*;
192192

scylla/src/errors.rs scylla/src/transport/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ pub(crate) enum ResponseParseError {
668668
mod tests {
669669
use scylla_cql::Consistency;
670670

671-
use crate::errors::{DbError, QueryError, WriteType};
671+
use crate::transport::errors::{DbError, QueryError, WriteType};
672672

673673
#[test]
674674
fn write_type_from_str() {

scylla/src/transport/iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use super::execution_profile::ExecutionProfileInner;
1919
use super::session::RequestSpan;
2020
use crate::cql_to_rust::{FromRow, FromRowError};
2121

22-
use crate::errors::{QueryError, UserRequestError};
2322
use crate::frame::response::{
2423
result,
2524
result::{ColumnSpec, Row, Rows},
@@ -29,6 +28,7 @@ use crate::statement::{prepared_statement::PreparedStatement, query::Query};
2928
use crate::statement::{Consistency, PagingState, SerialConsistency};
3029
use crate::transport::cluster::ClusterData;
3130
use crate::transport::connection::{Connection, NonErrorQueryResponse, QueryResponse};
31+
use crate::transport::errors::{QueryError, UserRequestError};
3232
use crate::transport::load_balancing::{self, RoutingInfo};
3333
use crate::transport::metrics::Metrics;
3434
use crate::transport::retry_policy::{QueryInfo, RetryDecision, RetrySession};
@@ -416,7 +416,7 @@ mod checked_channel_sender {
416416
use tokio::sync::mpsc;
417417
use uuid::Uuid;
418418

419-
use crate::errors::QueryError;
419+
use crate::transport::errors::QueryError;
420420

421421
use super::ReceivedPage;
422422

scylla/src/transport/large_batch_statements_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use assert_matches::assert_matches;
22

33
use crate::batch::BatchType;
4-
use crate::errors::{BadQuery, QueryError};
54
use crate::query::Query;
65
use crate::test_utils::setup_tracing;
6+
use crate::transport::errors::{BadQuery, QueryError};
77
use crate::{
88
batch::Batch,
99
test_utils::{create_new_session_builder, unique_keyspace_name},

scylla/src/transport/load_balancing/default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pub use self::latency_awareness::LatencyAwarenessBuilder;
33

44
use super::{FallbackPlan, LoadBalancingPolicy, NodeRef, RoutingInfo};
55
use crate::{
6-
errors::QueryError,
76
routing::{Shard, Token},
7+
transport::errors::QueryError,
88
transport::{cluster::ClusterData, locator::ReplicaSet, node::Node, topology::Strategy},
99
};
1010
use itertools::{Either, Itertools};
@@ -2550,9 +2550,9 @@ mod latency_awareness {
25502550
use uuid::Uuid;
25512551

25522552
use crate::{
2553-
errors::{DbError, QueryError},
25542553
load_balancing::NodeRef,
25552554
routing::Shard,
2555+
transport::errors::{DbError, QueryError},
25562556
transport::node::Node,
25572557
};
25582558
use std::{

scylla/src/transport/load_balancing/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
use super::{cluster::ClusterData, NodeRef};
66
use crate::{
7-
errors::QueryError,
87
routing::{Shard, Token},
8+
transport::errors::QueryError,
99
};
1010
use scylla_cql::frame::{response::result::TableSpec, types};
1111

scylla/src/transport/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod cluster;
33
pub(crate) mod connection;
44
mod connection_pool;
55
pub mod downgrading_consistency_retry_policy;
6+
pub mod errors;
67
pub mod execution_profile;
78
pub mod host_filter;
89
pub mod iterator;

scylla/src/transport/node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use tokio::net::lookup_host;
22
use tracing::warn;
33
use uuid::Uuid;
44

5-
use crate::errors::{ConnectionPoolError, QueryError};
65
/// Node represents a cluster node along with it's data and connections
76
use crate::routing::{Shard, Sharder};
87
use crate::transport::connection::Connection;
98
use crate::transport::connection::VerifiedKeyspaceName;
109
use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig};
10+
use crate::transport::errors::{ConnectionPoolError, QueryError};
1111

1212
use std::fmt::Display;
1313
use std::io;

scylla/src/transport/retry_policy.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! To decide when to retry a query the `Session` can use any object which implements
33
//! the `RetryPolicy` trait
44
5-
use crate::errors::{DbError, QueryError, WriteType};
65
use crate::frame::types::Consistency;
6+
use crate::transport::errors::{DbError, QueryError, WriteType};
77

88
/// Information about a failed query
99
pub struct QueryInfo<'a> {
@@ -219,10 +219,10 @@ impl RetrySession for DefaultRetrySession {
219219
#[cfg(test)]
220220
mod tests {
221221
use super::{DefaultRetryPolicy, QueryInfo, RetryDecision, RetryPolicy};
222-
use crate::errors::{BadQuery, QueryError};
223-
use crate::errors::{DbError, WriteType};
224222
use crate::statement::Consistency;
225223
use crate::test_utils::setup_tracing;
224+
use crate::transport::errors::{BadQuery, QueryError};
225+
use crate::transport::errors::{DbError, WriteType};
226226
use bytes::Bytes;
227227
use std::io::ErrorKind;
228228
use std::sync::Arc;

scylla/src/transport/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use crate::batch::batch_values;
55
#[cfg(feature = "cloud")]
66
use crate::cloud::CloudConfig;
77

8-
pub use crate::errors::TranslationError;
9-
use crate::errors::{BadQuery, NewSessionError, QueryError, UserRequestError};
108
use crate::history;
119
use crate::history::HistoryListener;
10+
pub use crate::transport::errors::TranslationError;
11+
use crate::transport::errors::{BadQuery, NewSessionError, QueryError, UserRequestError};
1212
use crate::utils::pretty::{CommaSeparatedDisplayer, CqlValueDisplayer};
1313
use arc_swap::ArcSwapOption;
1414
use async_trait::async_trait;

scylla/src/transport/session_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::Compression;
77

88
#[cfg(feature = "cloud")]
99
use crate::cloud::{CloudConfig, CloudConfigError};
10-
use crate::errors::NewSessionError;
10+
use crate::transport::errors::NewSessionError;
1111
#[cfg(feature = "cloud")]
1212
use crate::ExecutionProfile;
1313

scylla/src/transport/session_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate as scylla;
22
use crate::batch::{Batch, BatchStatement};
3-
use crate::errors::{BadKeyspaceName, BadQuery, DbError, QueryError};
43
use crate::frame::response::result::Row;
54
use crate::prepared_statement::PreparedStatement;
65
use crate::query::Query;
@@ -10,6 +9,7 @@ use crate::statement::Consistency;
109
use crate::test_utils::{scylla_supports_tablets, setup_tracing};
1110
use crate::tracing::TracingInfo;
1211
use crate::transport::cluster::Datacenter;
12+
use crate::transport::errors::{BadKeyspaceName, BadQuery, DbError, QueryError};
1313
use crate::transport::partitioner::{
1414
calculate_token_for_partition_key, Murmur3Partitioner, Partitioner, PartitionerName,
1515
};
@@ -2526,7 +2526,7 @@ async fn test_rate_limit_exceeded_exception() {
25262526
}
25272527
}
25282528

2529-
use crate::errors::OperationType;
2529+
use crate::transport::errors::OperationType;
25302530

25312531
match maybe_err.expect("Rate limit error didn't occur") {
25322532
QueryError::DbError(DbError::RateLimitReached { op_type, .. }, _) => {

scylla/src/transport/speculative_execution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use futures::{
55
use std::{future::Future, sync::Arc, time::Duration};
66
use tracing::{trace_span, warn, Instrument};
77

8-
use crate::errors::QueryError;
8+
use crate::transport::errors::QueryError;
99

1010
use super::metrics::Metrics;
1111

scylla/src/transport/topology.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::errors::{DbError, NewSessionError, QueryError};
21
use crate::frame::response::event::Event;
32
use crate::routing::Token;
43
use crate::statement::query::Query;
54
use crate::transport::connection::{Connection, ConnectionConfig};
65
use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig, PoolSize};
6+
use crate::transport::errors::{DbError, NewSessionError, QueryError};
77
use crate::transport::host_filter::HostFilter;
88
use crate::transport::node::resolve_contact_points;
99
use crate::utils::parse::{ParseErrorCause, ParseResult, ParserState};

scylla/tests/integration/execution_profiles.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<const NODE: u8> LoadBalancingPolicy for BoundToPredefinedNodePolicy<NODE> {
8181
_query: &RoutingInfo,
8282
_latency: std::time::Duration,
8383
_node: NodeRef<'_>,
84-
_error: &scylla::errors::QueryError,
84+
_error: &scylla::transport::errors::QueryError,
8585
) {
8686
}
8787

scylla/tests/integration/new_session.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::utils::setup_tracing;
22

33
use assert_matches::assert_matches;
4-
use scylla::errors::NewSessionError;
4+
use scylla::transport::errors::NewSessionError;
55
use scylla::SessionBuilder;
66

77
#[cfg(not(scylla_cloud_tests))]

scylla/tests/integration/tablets.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use scylla::ExecutionProfile;
2020
use scylla::QueryResult;
2121
use scylla::Session;
2222

23-
use scylla::errors::QueryError;
23+
use scylla::transport::errors::QueryError;
2424
use scylla_proxy::{
2525
Condition, ProxyError, Reaction, ResponseFrame, ResponseOpcode, ResponseReaction, ResponseRule,
2626
ShardAwareness, TargetShard, WorkerError,

0 commit comments

Comments
 (0)