Add Error::is_not_found or similar
jplatte opened this issue · comments
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.
SGTM!
Should probably add a .kind()
method which returns a fieldless nonexhaustive enum.
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).