8000 fix(daemon): Add context to error when unable to connect by jeremycline · Pull Request #2394 · atuinsh/atuin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(daemon): Add context to error when unable to connect #2394

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

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/atuin-daemon/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use eyre::{eyre, Result};
use eyre::{Context, Result};
#[cfg(windows)]
use tokio::net::TcpStream;
use tonic::transport::{Channel, Endpoint, Uri};
Expand All @@ -23,6 +23,7 @@ pub struct HistoryClient {
impl HistoryClient {
#[cfg(unix)]
pub async fn new(path: String) -> Result<Self> {
let log_path = path.clone();
let channel = Endpoint::try_from("http://atuin_local_daemon:0")?
.connect_with_connector(service_fn(move |_: Uri| {
let path = path.clone();
Expand All @@ -32,7 +33,12 @@ impl HistoryClient {
}
}))
.await
.map_err(|_| eyre!("failed to connect to local atuin daemon. Is it running?"))?;
.wrap_err_with(|| {
format!(
"failed to connect to local atuin daemon at {}. Is it running?",
&log_path
)
})?;

let client = HistoryServiceClient::new(channel);

Expand All @@ -50,7 +56,12 @@ impl HistoryClient {
}
}))
.await
.map_err(|_| eyre!("failed to connect to local atuin daemon. Is it running?"))?;
.wrap_err_with(|| {
format!(
"failed to connect to local atuin daemon at 127.0.0.1:{}. Is it running?",
port
)
})?;

let client = HistoryServiceClient::new(channel);

Expand Down
0