Read about our upcoming Code of Conduct on this issue

Commit 9c88bb19 authored by Antoine Cezar's avatar Antoine Cezar
Browse files

rhg: handle broken pipe error for stderr

Differential Revision: https://phab.mercurial-scm.org/D8871
parent 10c36ead86f8
......@@ -49,7 +49,7 @@ impl Ui {
.write_all(bytes)
.or_else(|e| handle_stderr_error(e))?;
stderr.flush().or_else(|e| Err(UiError::StderrError(e)))
stderr.flush().or_else(|e| handle_stderr_error(e))
}
}
......@@ -94,3 +94,13 @@ fn handle_stdout_error(error: io::Error) -> Result<(), UiError> {
Err(UiError::StdoutError(error))
}
/// Sometimes writing to stderr is not possible.
fn handle_stderr_error(error: io::Error) -> Result<(), UiError> {
// A broken pipe should not result in a error
// like with `| head` for example
if let ErrorKind::BrokenPipe = error.kind() {
return Ok(());
}
Err(UiError::StdoutError(error))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment