Skip to content
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

Add Error::is_not_found or similar #46

Open
jplatte opened this issue Mar 2, 2022 · 2 comments
Open

Add Error::is_not_found or similar #46

jplatte opened this issue Mar 2, 2022 · 2 comments

Comments

@jplatte
Copy link

jplatte commented Mar 2, 2022

Use case: Some automation tools require other binaries to be installed. I would like to catch when that is not the case and print installation instructions.

@matklad
Copy link
Owner

matklad commented Mar 2, 2022

SGTM!

Should probably add a .kind() method which returns a fieldless nonexhaustive enum.

@matklad
Copy link
Owner

matklad commented Jul 11, 2023

Thinking about the broader problem, I think for myself I usually use the following pattern:

if cmd!(sh, "my-tool --version").run().is_err() {
    eprintln!("Install my tool");
    return
}

That is perhaps a better behavior than catching the error after-the-fact, because:

  • it's more transactional (we don't abort in the middle of the process)
  • you also see a version of the tool printed to the screen, which helps with debugging issues when the tool exixsts, but it has wrong version (thinking about weird CI case mostly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants