Skip to content

Commit e379289

Browse files
committed
sharding: fix error messages in ShardingError
1 parent deb068b commit e379289

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

scylla/src/routing/sharding.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,21 @@ pub enum ShardingError {
101101
/// Unless, there is some serious bug in Scylla.
102102
#[error("Server did not provide any sharding information")]
103103
NoShardInfo,
104-
#[error("ShardInfo parameters missing")]
105-
MissingShardInfoParameter,
106-
#[error("ShardInfo parameters missing after unwrapping")]
107-
MissingUnwrapedShardInfoParameter,
108-
#[error("ShardInfo contains an invalid number of shards (0)")]
104+
105+
/// A bug in scylla. Some of the parameters are present, while others are missing.
106+
#[error("Missing some sharding info parameters")]
107+
MissingSomeShardInfoParameters,
108+
109+
/// A bug in Scylla. All parameters are present, but some do not contain any values.
110+
#[error("Missing some sharding info parameter values")]
111+
MissingShardInfoParameterValues,
112+
113+
/// A bug in Scylla. Number of shards is equal to zero.
114+
#[error("Sharding info contains an invalid number of shards (0)")]
109115
ZeroShards,
110-
#[error("ParseIntError encountered while getting ShardInfo")]
116+
117+
/// A bug in Scylla. Failed to parse string to number.
118+
#[error("Failed to parse a sharding info parameter's value: {0}")]
111119
ParseIntError(#[from] std::num::ParseIntError),
112120
}
113121

@@ -131,7 +139,7 @@ impl<'a> TryFrom<&'a HashMap<String, Vec<String>>> for ShardInfo {
131139
// All parameters are missing - most likely a Cassandra cluster.
132140
(None, None, None) => return Err(ShardingError::NoShardInfo),
133141
// At least one of the parameters is present, but some are missing. A bug in Scylla.
134-
_ => return Err(ShardingError::MissingShardInfoParameter),
142+
_ => return Err(ShardingError::MissingSomeShardInfoParameters),
135143
};
136144

137145
// Further unwrap entries (they should be the first entries of their corresponding Vecs).
@@ -140,7 +148,7 @@ impl<'a> TryFrom<&'a HashMap<String, Vec<String>>> for ShardInfo {
140148
nr_shards_entry.first(),
141149
msb_ignore_entry.first(),
142150
) else {
143-
return Err(ShardingError::MissingUnwrapedShardInfoParameter);
151+
return Err(ShardingError::MissingShardInfoParameterValues);
144152
};
145153

146154
let shard = shard_entry.parse::<u16>()?;

0 commit comments

Comments
 (0)