-
Notifications
You must be signed in to change notification settings - Fork 0
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
sshforwarding: exit on ssh errors without printing any further errors #9
Conversation
bcb56de
to
0bdfa31
Compare
@@ -54,15 +54,15 @@ async fn main() -> io::Result<()> { | |||
init_logging(&log_args); | |||
|
|||
if let Err(err) = run(command).await.as_ref() { | |||
tracing::error!(error = ?err, "network tunnel failed."); | |||
tracing::error!(error = %err, "network tunnel failed."); |
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.
% signifies the Display
implementation of the error, rather than its Debug
implementation, so the error looks more human-readable rather than exposing the underlying error struct
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.
This makes sense and is fine for std::io::Result
👍 But a general informational comment:
We use a lot of anyhow::Result
which is a really nice crate for chaining errors with contextual information and back traces, and I generally recommend it for all top-level handling of errors.
For anyhow::Result, we always want to use the ?err
form when used in a tracing::* message, because that renders the complete error chain in a human-readable fashion. We've previously had situations where we were using the %err
form accidentally, which only renders the top-most error context of the chain, and then had to go back and switch to ?err
as part of an investigation because the meat of the error was lost.
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.
LGTM
@@ -54,15 +54,15 @@ async fn main() -> io::Result<()> { | |||
init_logging(&log_args); | |||
|
|||
if let Err(err) = run(command).await.as_ref() { | |||
tracing::error!(error = ?err, "network tunnel failed."); | |||
tracing::error!(error = %err, "network tunnel failed."); |
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.
This makes sense and is fine for std::io::Result
👍 But a general informational comment:
We use a lot of anyhow::Result
which is a really nice crate for chaining errors with contextual information and back traces, and I generally recommend it for all top-level handling of errors.
For anyhow::Result, we always want to use the ?err
form when used in a tracing::* message, because that renders the complete error chain in a human-readable fashion. We've previously had situations where we were using the %err
form accidentally, which only renders the top-most error context of the chain, and then had to go back and switch to ?err
as part of an investigation because the meat of the error was lost.
This will allow us to give the SSH client's error directly to the user as the last error.
Example output: