diff --git a/picoplugin/src/error_code.rs b/picoplugin/src/error_code.rs index 6c23eb3399e56935f6ee04cd9ba6dddcfd57cff4..0de0c5db2a7a234502f614f2f1f3d044df949edd 100644 --- a/picoplugin/src/error_code.rs +++ b/picoplugin/src/error_code.rs @@ -36,6 +36,7 @@ tarantool::define_enum_with_introspection! { WrongPluginVersion = 10015, NoSuchInstance = 10016, + NoSuchReplicaset = 10017, // TODO: put in particular compare-and-swap related ones, but also other ones diff --git a/src/traft/error.rs b/src/traft/error.rs index 8cbb7f6f6f3c21652067ea93a426a272c3a60594..02e7028a8c169f21615a2d9be602418924c9e333 100644 --- a/src/traft/error.rs +++ b/src/traft/error.rs @@ -54,7 +54,7 @@ pub enum Error { Tarantool(#[from] ::tarantool::error::Error), #[error("instance with {} not found", DisplayIdOfInstance(.0))] NoSuchInstance(Result<RaftId, InstanceId>), - #[error("replicaset with {} \"{id}\" not found", if *.id_is_uuid { "uuid" } else { "id" })] + #[error("replicaset with {} \"{id}\" not found", if *.id_is_uuid { "replicaset_uuid" } else { "replicaset_id" })] NoSuchReplicaset { id: String, id_is_uuid: bool }, #[error("address of peer with id {0} not found")] AddressUnknownForRaftId(RaftId), @@ -207,6 +207,9 @@ impl IntoBoxError for Error { Self::NoSuchInstance { .. } => { BoxError::new(ErrorCode::NoSuchInstance, self.to_string()) } + Self::NoSuchReplicaset { .. } => { + BoxError::new(ErrorCode::NoSuchReplicaset, self.to_string()) + } // TODO: give other error types specific codes other => BoxError::new(ErrorCode::Other, other.to_string()), } diff --git a/test/conftest.py b/test/conftest.py index 855a4193bab5b7d409c76ff21b6ef77e1805b5a9..4ff0dbcd3f5bc5fd0ded58054061a4229318fcc9 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -59,6 +59,7 @@ PICO_SERVICE_ID = 32 class ErrorCode: Loading = 116 NoSuchInstance = 10016 + NoSuchReplicaset = 10017 def eprint(*args, **kwargs): diff --git a/test/int/test_plugin.py b/test/int/test_plugin.py index e6a32f5c39147027c16e5eef477c2c0309ebf3ed..c8bdb09248affd3c16afc955b779f8326094b739 100644 --- a/test/int/test_plugin.py +++ b/test/int/test_plugin.py @@ -1810,11 +1810,7 @@ def test_plugin_rpc_sdk_send_request(cluster: Cluster): ) # Check requesting RPC to unknown replicaset - with pytest.raises( - TarantoolError, - # FIXME: do a better error message - match='replicaset with id "NO_SUCH_REPLICASET" not found', - ): + with pytest.raises(TarantoolError) as e: context = make_context() input = dict( path="/ping", @@ -1822,6 +1818,10 @@ def test_plugin_rpc_sdk_send_request(cluster: Cluster): input=msgpack.dumps([]), ) i1.call(".proc_rpc_dispatch", "/proxy", msgpack.dumps(input), context) + assert e.value.args[:2] == ( + ErrorCode.NoSuchReplicaset, + 'replicaset with replicaset_id "NO_SUCH_REPLICASET" not found', + ) # Check requesting RPC to unknown bucket id with pytest.raises(