diff --git a/crates/fluvio/src/admin.rs b/crates/fluvio/src/admin.rs index 771f843853..81df8693f4 100644 --- a/crates/fluvio/src/admin.rs +++ b/crates/fluvio/src/admin.rs @@ -22,8 +22,9 @@ use fluvio_sc_schema::{AdminSpec, DeletableAdminSpec, CreatableAdminSpec, TryEnc use fluvio_socket::{ClientConfig, VersionedSerialSocket, SerialFrame, MultiplexerSocket}; use crate::FluvioConfig; -use crate::metadata::objects::{ListResponse, ListRequest}; use crate::config::ConfigFile; +use crate::error::anyhow_version_error; +use crate::metadata::objects::{ListResponse, ListRequest}; use crate::sync::MetadataStores; /// An interface for managing a Fluvio cluster @@ -135,9 +136,8 @@ impl FluvioAdmin { metadata, }) } else { - let platform_version = versions.platform_version(); - let client_version = crate::VERSION.trim(); - Err(anyhow!("Fluvio Client {client_version} and Cluster {platform_version} versions are not compatible. Please upgrade client to {platform_version}")) + let platform_version = versions.platform_version().to_string(); + Err(anyhow_version_error(&platform_version)) } } diff --git a/crates/fluvio/src/error.rs b/crates/fluvio/src/error.rs index d3c161a52e..27aa88edd0 100644 --- a/crates/fluvio/src/error.rs +++ b/crates/fluvio/src/error.rs @@ -68,3 +68,9 @@ To interact with this cluster, please install the matching CLI version using the #[error("Unknown error: {0}")] Other(String), } + +pub fn anyhow_version_error(platform_ver: &str) -> anyhow::Error { + use anyhow::anyhow; + let client_ver = crate::VERSION.trim(); + anyhow!("Fluvio Client {client_ver} and Cluster {platform_ver} versions are not compatible. Please use a client compatible with {platform_ver}") +} diff --git a/crates/fluvio/src/fluvio.rs b/crates/fluvio/src/fluvio.rs index 40e0c50fb9..20fcc8f3d8 100644 --- a/crates/fluvio/src/fluvio.rs +++ b/crates/fluvio/src/fluvio.rs @@ -7,7 +7,7 @@ use fluvio_sc_schema::topic::PartitionMap; use fluvio_sc_schema::topic::ReplicaSpec; use tracing::{debug, info}; use tokio::sync::OnceCell; -use anyhow::{anyhow, Result}; +use anyhow::Result; use fluvio_sc_schema::objects::ObjectApiWatchRequest; use fluvio_types::PartitionId; @@ -18,6 +18,7 @@ use fluvio_future::net::DomainConnector; use semver::Version; use crate::admin::FluvioAdmin; +use crate::error::anyhow_version_error; use crate::producer::TopicProducerPool; use crate::spu::SpuPool; use crate::TopicProducer; @@ -122,9 +123,8 @@ impl Fluvio { metric: Arc::new(ClientMetrics::new()), }) } else { - let platform_version = versions.platform_version(); - let client_version = crate::VERSION.trim(); - Err(anyhow!("Fluvio Client {client_version} and Cluster {platform_version} versions are not compatible. Please upgrade client to {platform_version}")) + let platform_version = versions.platform_version().to_string(); + Err(anyhow_version_error(&platform_version)) } }