Improve display of version mismatch error

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent ee9d4b0312
commit 5fee8a2e4a

@ -1,6 +1,6 @@
[package]
name = "mediarepo-api"
version = "0.4.1"
version = "0.4.2"
edition = "2018"
license = "gpl-3"

@ -7,6 +7,6 @@ pub enum ApiError {
#[error(transparent)]
IPC(#[from] rmp_ipc::error::Error),
#[error("The servers api version is incompatible with the api client")]
VersionMismatch,
#[error("The servers api version (version {server:?}) is incompatible with the api client {client:?}")]
VersionMismatch { server: String, client: String },
}

@ -77,7 +77,15 @@ impl ApiClient {
let server_api_version = info.api_version();
if !check_apis_compatible(get_api_version(), server_api_version) {
Err(ApiError::VersionMismatch)
let server_version_string = format!(
"{}.{}.{}",
server_api_version.0, server_api_version.1, server_api_version.2
);
let client_version_string = env!("CARGO_PKG_VERSION").to_string();
Err(ApiError::VersionMismatch {
server: server_version_string,
client: client_version_string,
})
} else {
Ok(client)
}

@ -46,7 +46,9 @@ impl From<ApiError> for PluginError {
format!("{:?}", e)
}
},
ApiError::VersionMismatch => {String::from("The servers API version is not supported by the client. Please make sure both are up to date.")}
ApiError::VersionMismatch { server, client } => {
format!("The servers API version ({}) is not supported by the client ({}). Please make sure both are up to date.", server, client)
}
};
Self { message }
}

Loading…
Cancel
Save