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:
parent
d2d01e77e3
commit
75da247317
1 changed files with 13 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue