Skip to content

Commit

Permalink
improve error reporting (#48)
Browse files Browse the repository at this point in the history
* add error context to connect function

* update connect error message to be more contextual

* fix clippy issue

* add new line in cargo.toml file
  • Loading branch information
MarioBassem authored May 22, 2023
1 parent 4992281 commit fe9b915
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/app/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,12 @@ impl Client {
}

async fn connect(&self) -> Result<UnixStream> {
Ok(UnixStream::connect(&self.socket).await?)
UnixStream::connect(&self.socket).await.with_context(|| {
format!(
"failed to connect to '{:?}'. is zinit listening on that socket?",
self.socket
)
})
}

async fn command(&self, c: &str) -> Result<Value> {
Expand Down

0 comments on commit fe9b915

Please sign in to comment.