diff --git a/scylla/src/errors.rs b/scylla/src/errors.rs index 162aba5e0..17fc09d96 100644 --- a/scylla/src/errors.rs +++ b/scylla/src/errors.rs @@ -71,9 +71,11 @@ pub enum QueryError { #[error("Timeout Error")] TimeoutError, + /// A connection has been broken during query execution. #[error(transparent)] BrokenConnection(#[from] BrokenConnectionError), + /// Driver was unable to allocate a stream id to execute a query on. #[error("Unable to allocate stream id")] UnableToAllocStreamId, @@ -223,9 +225,11 @@ pub enum NewSessionError { #[error("Timeout Error")] TimeoutError, + /// A connection has been broken during query execution. #[error(transparent)] BrokenConnection(#[from] BrokenConnectionError), + /// Driver was unable to allocate a stream id to execute a query on. #[error("Unable to allocate stream id")] UnableToAllocStreamId, @@ -284,12 +288,17 @@ pub enum BadKeyspaceName { #[derive(Error, Debug, Clone)] #[non_exhaustive] pub enum ConnectionPoolError { + /// A connection pool is broken. Includes an error of a last connection. #[error("The pool is broken; Last connection failed with: {last_connection_error}")] Broken { last_connection_error: ConnectionError, }, + + /// A connection pool is still being initialized. #[error("Pool is still being initialized")] Initializing, + + /// A corresponding node was disabled by a host filter. #[error("The node has been disabled by a host filter")] NodeDisabledByHostFilter, } @@ -300,16 +309,27 @@ pub enum ConnectionPoolError { #[derive(Error, Debug, Clone)] #[non_exhaustive] pub enum ConnectionError { + /// Provided connect timeout elapsed. #[error("Connect timeout elapsed")] ConnectTimeout, + + /// Input/Output error occurred. #[error(transparent)] IoError(Arc), + + /// Driver was unable to find a free source port for given shard. #[error("Could not find free source port for shard {0}")] NoSourcePortForShard(u32), + + /// Failed to translate an address before establishing a connection. #[error("Address translation failed: {0}")] TranslationError(#[from] TranslationError), + + /// A connection has been broken after being established. #[error(transparent)] BrokenConnection(#[from] BrokenConnectionError), + + /// A request required to initialize a connection failed. #[error(transparent)] ConnectionSetupRequestError(#[from] ConnectionSetupRequestError), } @@ -340,8 +360,11 @@ impl ConnectionError { /// Error caused by failed address translation done before establishing connection #[derive(Debug, Clone, Error)] pub enum TranslationError { + /// Driver failed to find a translation rule for a provided address. #[error("No rule for address {0}")] NoRuleForAddress(SocketAddr), + + /// A translation rule for a provided address was found, but the translated address was invalid. #[error("Failed to parse translated address: {translated_addr_str}, reason: {reason}")] InvalidAddressInRule { translated_addr_str: &'static str, @@ -362,32 +385,60 @@ pub struct ConnectionSetupRequestError { #[non_exhaustive] pub enum ConnectionSetupRequestErrorKind { // TODO: Make FrameError clonable. + /// An error occurred when parsing response frame header. #[error(transparent)] FrameError(Arc), + + /// Driver was unable to allocate a stream id to execute a setup request on. #[error("Unable to allocate stream id")] UnableToAllocStreamId, + + /// A connection was broken during setup request execution. #[error(transparent)] BrokenConnection(#[from] BrokenConnectionError), + + /// Received a server error in response to connection setup request. #[error("Database returned an error: {0}, Error message: {1}")] DbError(DbError, String), + + /// Received an unexpected response from the server. #[error("Received unexpected response from the server: {0}")] UnexpectedResponse(CqlResponseKind), + + /// Received a response to OPTIONS request, but failed to deserialize its body. #[error("Failed to deserialize SUPPORTED response: {0}")] CqlSupportedParseError(#[from] CqlSupportedParseError), + + /// Received an AUTHENTICATE response, but failed to deserialize its body. #[error("Failed to deserialize AUTHENTICATE response: {0}")] CqlAuthenticateParseError(#[from] CqlAuthenticateParseError), + + /// Received an AUTH_SUCCESS response, but failed to deserialize its body. #[error("Failed to deserialize AUTH_SUCCESS response: {0}")] CqlAuthSuccessParseError(#[from] CqlAuthSuccessParseError), + + /// Received an AUTH_CHALLENGE response, but failed to deserialize its body. #[error("Failed to deserialize AUTH_CHALLENGE response: {0}")] CqlAuthChallengeParseError(#[from] CqlAuthChallengeParseError), + + /// Received server ERROR response, but failed to deserialize its body. #[error("Failed to deserialize ERROR response: {0}")] CqlErrorParseError(#[from] CqlErrorParseError), + + /// An error returned by [`AuthenticatorProvider::start_authentication_session`](crate::authentication::AuthenticatorProvider::start_authentication_session). #[error("Failed to start client's auth session: {0}")] StartAuthSessionError(AuthError), + + /// An error returned by [`AuthenticatorSession::evaluate_challenge`](crate::authentication::AuthenticatorSession::evaluate_challenge). #[error("Failed to evaluate auth challenge on client side: {0}")] AuthChallengeEvaluationError(AuthError), + + /// An error returned by [`AuthenticatorSession::success`](crate::authentication::AuthenticatorSession::success). #[error("Failed to finish auth challenge on client side: {0}")] AuthFinishError(AuthError), + + /// User did not provide authentication. See [`SessionBuilder::user`](crate::transport::session_builder::SessionBuilder::user) + /// and/or [`SessionBuilder::authenticator_provider`](crate::transport::session_builder::SessionBuilder::authenticator_provider). #[error("Authentication is required. You can use SessionBuilder::user(\"user\", \"pass\") to provide credentials or SessionBuilder::authenticator_provider to provide custom authenticator")] MissingAuthentication, }