Skip to content

Commit e23e316

Browse files
authored
Merge pull request #1194 from muzarski/tracing-error
errors: rename and extract TracingError
2 parents 699e389 + a676f32 commit e23e316

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

scylla/src/client/session.rs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::cluster::node::{InternalKnownNode, KnownNode, NodeRef};
1515
use crate::cluster::{Cluster, ClusterNeatDebug, ClusterState};
1616
use crate::errors::{
1717
BadQuery, ExecutionError, MetadataError, NewSessionError, PrepareError, ProtocolError,
18-
RequestAttemptError, RequestError, TracingProtocolError, UseKeyspaceError,
18+
RequestAttemptError, RequestError, TracingError, UseKeyspaceError,
1919
};
2020
use crate::frame::response::result;
2121
#[cfg(feature = "ssl")]
@@ -1550,7 +1550,7 @@ impl Session {
15501550
///
15511551
/// See [the book](https://rust-driver.docs.scylladb.com/stable/tracing/tracing.html)
15521552
/// for more information about query tracing
1553-
pub async fn get_tracing_info(&self, tracing_id: &Uuid) -> Result<TracingInfo, ExecutionError> {
1553+
pub async fn get_tracing_info(&self, tracing_id: &Uuid) -> Result<TracingInfo, TracingError> {
15541554
// tracing_info_fetch_attempts is NonZeroU32 so at least one attempt will be made
15551555
for _ in 0..self.tracing_info_fetch_attempts.get() {
15561556
let current_try: Option<TracingInfo> = self
@@ -1563,7 +1563,7 @@ impl Session {
15631563
};
15641564
}
15651565

1566-
Err(ProtocolError::Tracing(TracingProtocolError::EmptyResults).into())
1566+
Err(TracingError::EmptyResults)
15671567
}
15681568

15691569
/// Gets the name of the keyspace that is currently set, or `None` if no
@@ -1588,7 +1588,7 @@ impl Session {
15881588
&self,
15891589
tracing_id: &Uuid,
15901590
consistency: Option<Consistency>,
1591-
) -> Result<Option<TracingInfo>, ExecutionError> {
1591+
) -> Result<Option<TracingInfo>, TracingError> {
15921592
// Query system_traces.sessions for TracingInfo
15931593
let mut traces_session_query =
15941594
Query::new(crate::observability::tracing::TRACES_SESSION_QUERY_STR);
@@ -1609,17 +1609,15 @@ impl Session {
16091609
// Get tracing info
16101610
let maybe_tracing_info: Option<TracingInfo> = traces_session_res
16111611
.into_rows_result()
1612-
.map_err(|err| {
1613-
ProtocolError::Tracing(TracingProtocolError::TracesSessionIntoRowsResultError(err))
1614-
})?
1612+
.map_err(TracingError::TracesSessionIntoRowsResultError)?
16151613
.maybe_first_row()
16161614
.map_err(|err| match err {
16171615
MaybeFirstRowError::TypeCheckFailed(e) => {
1618-
ProtocolError::Tracing(TracingProtocolError::TracesSessionInvalidColumnType(e))
1616+
TracingError::TracesSessionInvalidColumnType(e)
1617+
}
1618+
MaybeFirstRowError::DeserializationFailed(e) => {
1619+
TracingError::TracesSessionDeserializationFailed(e)
16191620
}
1620-
MaybeFirstRowError::DeserializationFailed(e) => ProtocolError::Tracing(
1621-
TracingProtocolError::TracesSessionDeserializationFailed(e),
1622-
),
16231621
})?;
16241622

16251623
let mut tracing_info = match maybe_tracing_info {
@@ -1628,20 +1626,16 @@ impl Session {
16281626
};
16291627

16301628
// Get tracing events
1631-
let tracing_event_rows_result = traces_events_res.into_rows_result().map_err(|err| {
1632-
ProtocolError::Tracing(TracingProtocolError::TracesEventsIntoRowsResultError(err))
1633-
})?;
1629+
let tracing_event_rows_result = traces_events_res
1630+
.into_rows_result()
1631+
.map_err(TracingError::TracesEventsIntoRowsResultError)?;
16341632
let tracing_event_rows = tracing_event_rows_result.rows().map_err(|err| match err {
1635-
RowsError::TypeCheckFailed(err) => {
1636-
ProtocolError::Tracing(TracingProtocolError::TracesEventsInvalidColumnType(err))
1637-
}
1633+
RowsError::TypeCheckFailed(err) => TracingError::TracesEventsInvalidColumnType(err),
16381634
})?;
16391635

16401636
tracing_info.events = tracing_event_rows
16411637
.collect::<Result<_, _>>()
1642-
.map_err(|err| {
1643-
ProtocolError::Tracing(TracingProtocolError::TracesEventsDeserializationFailed(err))
1644-
})?;
1638+
.map_err(TracingError::TracesEventsDeserializationFailed)?;
16451639

16461640
if tracing_info.events.is_empty() {
16471641
return Ok(None);

scylla/src/errors.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,6 @@ pub enum ProtocolError {
211211
#[error("Unable extract a partition key based on prepared statement's metadata")]
212212
PartitionKeyExtraction,
213213

214-
/// A protocol error occurred during tracing info fetch.
215-
#[error("Tracing info fetch protocol error: {0}")]
216-
Tracing(#[from] TracingProtocolError),
217-
218214
/// Driver tried to reprepare a statement in the batch, but the reprepared
219215
/// statement's id is not included in the batch.
220216
#[error("Reprepared statement's id does not exist in the batch.")]
@@ -261,10 +257,16 @@ pub enum SchemaVersionFetchError {
261257
SingleRowError(SingleRowError),
262258
}
263259

264-
/// A protocol error that occurred during tracing info fetch.
260+
/// An error that occurred during tracing info fetch.
265261
#[derive(Error, Debug, Clone)]
266262
#[non_exhaustive]
267-
pub enum TracingProtocolError {
263+
pub enum TracingError {
264+
/// Failed to execute query to either "system_traces.sessions" or "system_traces.events".
265+
#[error(
266+
"Failed to execute queries to \"system_traces.sessions\" or \"system_traces.events\" system tables: {0}"
267+
)]
268+
ExecutionError(#[from] ExecutionError),
269+
268270
/// Failed to convert result of system_traces.session query to rows result.
269271
#[error("Failed to convert result of system_traces.session query to rows result")]
270272
TracesSessionIntoRowsResultError(IntoRowsResultError),

0 commit comments

Comments
 (0)