Skip to content
Snippets Groups Projects
Commit 3c609337 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon: Committed by Georgy Moshkin
Browse files

rename: change up error messages so they are easier to parse from strings

parent f5744bf4
No related branches found
No related tags found
1 merge request!611Fix/reentarable pico schema change api
......@@ -288,43 +288,47 @@ crate::define_rpc_request! {
/// Usually it can't be handled and should be either retried from
/// scratch or returned to a user as is.
///
// NOTE: these error messages are relied on in luamod.lua,
// don't forget to update them everywhere if you're changing them.
#[derive(Debug, ::thiserror::Error)]
pub enum Error {
/// Can't check the predicate because raft log is compacted.
#[error("raft index {requested} is compacted at {compacted_index}")]
#[error("Compacted: raft index {requested} is compacted at {compacted_index}")]
Compacted {
requested: RaftIndex,
compacted_index: RaftIndex,
},
/// Nearly impossible error indicating invalid request.
#[error("raft entry at index {requested} does not exist yet, the last is {last_index}")]
#[error(
"NoSuchIndex: raft entry at index {requested} does not exist yet, the last is {last_index}"
)]
NoSuchIndex {
requested: RaftIndex,
last_index: RaftIndex,
},
/// Checking the predicate revealed a collision.
#[error("comparison failed for index {requested} as it conflicts with {conflict_index}")]
#[error("ConflictFound: comparison failed for index {requested} as it conflicts with {conflict_index}")]
ConflictFound {
requested: RaftIndex,
conflict_index: RaftIndex,
},
/// Checking the predicate revealed a collision.
#[error("entry at index {index} has term {actual_term}, request implies term {expected_term}")]
#[error("EntryTermMismatch: entry at index {index} has term {actual_term}, request implies term {expected_term}")]
EntryTermMismatch {
index: RaftIndex,
expected_term: RaftTerm,
actual_term: RaftTerm,
},
#[error("space {space} is prohibited for use in a predicate")]
#[error("SpaceNotAllowed: space {space} is prohibited for use in a predicate")]
SpaceNotAllowed { space: String },
/// An error related to `key_def` operation arised from tarantool
/// depths while checking the predicate.
#[error("failed comparing predicate ranges: {0}")]
#[error("KeyTypeMismatch: failed comparing predicate ranges: {0}")]
KeyTypeMismatch(#[from] TntError),
}
......
......@@ -35,11 +35,15 @@ pub enum Error {
instance_rsid: String,
requested_rsid: String,
},
// NOTE: this error message is relied on in luamod.lua,
// don't forget to update it everywhere if you're changing it.
#[error("operation request from different term {requested}, current term is {current}")]
TermMismatch {
requested: RaftTerm,
current: RaftTerm,
},
// NOTE: this error message is relied on in luamod.lua,
// don't forget to update it everywhere if you're changing it.
#[error("not a leader")]
NotALeader,
#[error("lua error: {0}")]
......@@ -61,7 +65,7 @@ pub enum Error {
#[error("governor has stopped")]
GovernorStopped,
#[error("compare-and-swap request failed: {0}")]
#[error("compare-and-swap: {0}")]
Cas(#[from] crate::cas::Error),
#[error("ddl failed: {0}")]
Ddl(#[from] crate::schema::DdlError),
......@@ -86,7 +90,7 @@ impl Error {
/// Temporary solution until proc_cas returns structured errors
pub fn is_cas_err(&self) -> bool {
self.to_string().contains("compare-and-swap request failed")
self.to_string().contains("compare-and-swap")
}
/// Temporary solution until proc_cas returns structured errors
......
......@@ -52,7 +52,7 @@ def test_cas_errors(instance: Instance):
)
assert e3.value.args == (
"ER_PROC_C",
"compare-and-swap request failed: entry at index 1 has term 1, request implies term 2",
"compare-and-swap: EntryTermMismatch: entry at index 1 has term 1, request implies term 2",
)
# Wrong index (too big)
......@@ -65,7 +65,7 @@ def test_cas_errors(instance: Instance):
)
assert e4.value.args == (
"ER_PROC_C",
"compare-and-swap request failed: "
"compare-and-swap: NoSuchIndex: "
+ f"raft entry at index 2048 does not exist yet, the last is {index}",
)
......@@ -77,7 +77,7 @@ def test_cas_errors(instance: Instance):
instance.cas("insert", "_pico_property", ["foo", "420"], index=index - 1)
assert e5.value.args == (
"ER_PROC_C",
"compare-and-swap request failed: "
"compare-and-swap: Compacted: "
+ f"raft index {index-1} is compacted at {index}",
)
......@@ -92,7 +92,7 @@ def test_cas_errors(instance: Instance):
)
assert e5.value.args == (
"ER_PROC_C",
f"compare-and-swap request failed: space {space} is prohibited for use "
f"compare-and-swap: SpaceNotAllowed: space {space} is prohibited for use "
+ "in a predicate",
)
......@@ -128,7 +128,7 @@ def test_cas_predicate(instance: Instance):
)
assert e5.value.args == (
"ER_PROC_C",
"compare-and-swap request failed: "
"compare-and-swap: ConflictFound: "
+ f"comparison failed for index {read_index} "
+ f"as it conflicts with {read_index+1}",
)
......@@ -194,7 +194,7 @@ def test_cas_lua_api(cluster: Cluster):
ranges=[CasRange(eq="fruit")],
)
assert e5.value.args == (
"compare-and-swap request failed: "
"compare-and-swap: ConflictFound: "
+ f"comparison failed for index {read_index} "
+ f"as it conflicts with {read_index+1}",
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment