-
-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(rust): display more detailed error messages to the user when create_outlet
fails
#5896
base: develop
Are you sure you want to change the base?
Conversation
… create_outlet fails
ac71287
to
6cbf68f
Compare
Thanks for contributing again! We really appreciate it! Inside the Ockam App we chose to use the term If we were to change the
Have you tried keeping the original error in ockam_api and see how they render in the app? |
Thanks @davide-baldo. Currently, the app shows a generic error message: "failed to create outlet". This is because the // ockam/implementations/rust/ockam/ockam_app/src/shared_service/tcp_outlet/create.rs
match node_manager
.create_outlet(
...
.await
{
Ok(status) => {
info!(socket_addr = socket_addr.to_string(), "Outlet created");
app_state.model_mut(|m| m.add_tcp_outlet(status)).await?;
system_tray_on_update(&app);
Ok(())
}
Err(e) => Err(Error::App(format!("{}", e).replacen("outlet", "service", 1))),
}?; Sounds reasonable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To complement @davide-baldo's review, here are some comments on how to explicitly handle the errors we want to bubble up to the app user.
@@ -55,7 +55,7 @@ impl NodeManager { | |||
|
|||
// Check that there is no entry in the registry with the same alias | |||
if self.registry.outlets.contains_key(&alias) { | |||
let message = format!("A TCP outlet with alias '{alias}' already exists"); | |||
let message = format!("A service with alias '{alias}' already exists"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service
concept is only relevant in the ockam_app
context. In the ockam_api
, an outlet is still an outlet, so we don't want to use the term service
here.
@@ -58,7 +58,7 @@ async fn tcp_outlet_create_impl( | |||
system_tray_on_update(&app); | |||
Ok(()) | |||
} | |||
Err(_) => Err(Error::App("Failed to create outlet".to_string())), | |||
Err(e) => Err(Error::App(format!("Failed to create service: {}", e))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the error message here can be literally anything, probably something very verbose and not user-friendly, so we shouldn't rely on it to show an error message to the user.
I'd revert this in favor of handling errors explicitly, as I mentioned in the previous comment.
@@ -55,7 +55,7 @@ impl NodeManager { | |||
|
|||
// Check that there is no entry in the registry with the same alias | |||
if self.registry.outlets.contains_key(&alias) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see here the alias is None
so, we are currently allowing the user to create different outlets with the same worker_addr
and/or same socket_addr
. Those are the two cases we want to handle explicitly, similarly to what we currently do checking for duplicated alias
.
As for the error messages, instead of using the `"A TCP outlet with name {name} already exists", perhaps you could write something like:
warn!("A TCP outlet with name {name} already exists");
let message = format!("name {name} already exists");
return Err(ockam_core::Error::new(...));
so that, in the ockam_app
you can add the prefix Failed to create service: {e}
.
Current behavior
Currently, when
NodeManager.create_outlet
returns an error,tcp_outlet_create_impl
(the caller) does not parse it and returns a generic error message instead and thus does not give the user enough information about what has caused the failure. Also, the error message use the term outlet which is considered to not be consistent with the UI, that instead refers to it as service.Proposed changes
Issue #5850
Including the source error message from
NodeManager.create_outlet
intcp_outlet_create_impl
and replacing the term outlet with service in those error messages.Checks