diff --git a/shared/grpc_clients/src/error.rs b/shared/grpc_clients/src/error.rs --- a/shared/grpc_clients/src/error.rs +++ b/shared/grpc_clients/src/error.rs @@ -1,4 +1,4 @@ -use tonic::{codegen::http::uri::InvalidUri, Status}; +use tonic::{codegen::http::uri::InvalidUri, Code, Status}; #[derive( Debug, derive_more::Display, derive_more::From, derive_more::Error, @@ -13,3 +13,12 @@ #[display(fmt = "Invalid Device Type")] InvalidDeviceType, } + +pub fn unsupported_version() -> Status { + Status::unimplemented("Unsupported version") +} + +pub fn is_version_unsupported(status: Status) -> bool { + status.code() == Code::Unimplemented + && status.message() == "Unsupported version" +}