Skip to content

Commit

Permalink
Fix wrong error code when subscribing to a non-existing path
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaeling committed Jun 28, 2023
1 parent 9ab495b commit 204596b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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"))
}
}
}

Expand Down

0 comments on commit 204596b

Please sign in to comment.