From 204596b36d54857a540b7275c9c5f1fa2555c22f Mon Sep 17 00:00:00 2001 From: rafaeling Date: Wed, 28 Jun 2023 13:19:09 +0200 Subject: [PATCH] Fix wrong error code when subscribing to a non-existing path --- .../databroker/src/grpc/kuksa_val_v1/val.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs index 7af4243a4..863233bc9 100644 --- a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs +++ b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs @@ -24,6 +24,7 @@ use tracing::debug; use crate::broker; use crate::broker::ReadError; +use crate::broker::SubscriptionError; use crate::permissions::Permissions; #[tonic::async_trait] @@ -326,10 +327,16 @@ impl proto::val_server::Val for broker::DataBroker { let stream = convert_to_proto_stream(stream); Ok(tonic::Response::new(Box::pin(stream))) } - Err(e) => Err(tonic::Status::new( + Err(SubscriptionError::NotFound) => { + Err(tonic::Status::new(tonic::Code::NotFound, "Path not found")) + } + Err(SubscriptionError::InvalidInput) => Err(tonic::Status::new( tonic::Code::InvalidArgument, - format!("{e:?}"), + "Invalid Argument", )), + Err(SubscriptionError::InternalError) => { + Err(tonic::Status::new(tonic::Code::Internal, "Internal Error")) + } } }