cli: Ignore BrokenPipe errors again

With the change to anyhow in the previous commit, we stopped ignoring
BrokenPipe errors.  Now we do again, not as a core part of our error
type, but as part of the `main` functions reaction to any error that
occurs.
This commit is contained in:
Douglas Creager 2021-06-09 15:13:14 -04:00
parent d2d01e77e3
commit 75da247317

View file

@ -13,6 +13,19 @@ const BUILD_VERSION: &'static str = env!("CARGO_PKG_VERSION");
const BUILD_SHA: Option<&'static str> = option_env!("BUILD_SHA");
fn main() -> Result<()> {
let result = run();
// Ignore BrokenPipe errors
if let Err(err) = &result {
if let Some(error) = err.downcast_ref::<std::io::Error>() {
if error.kind() == std::io::ErrorKind::BrokenPipe {
return Ok(());
}
}
}
result
}
fn run() -> Result<()> {
let version = if let Some(build_sha) = BUILD_SHA {
format!("{} ({})", BUILD_VERSION, build_sha)
} else {