fix(cli): Panic on broken pipe; use conditional match arm with ErrorKind

This commit is contained in:
Andrew Hlynskyi 2021-06-07 20:22:12 +03:00
parent 65dc922944
commit dbdda25224

View file

@ -1,6 +1,7 @@
use super::test_highlight;
use std::fmt::Write;
use std::io;
use std::io::ErrorKind;
use tree_sitter::{QueryError, QueryErrorKind};
use walkdir;
@ -106,8 +107,8 @@ impl From<serde_json::Error> for Error {
impl From<io::Error> for Error {
fn from(error: io::Error) -> Self {
match error.raw_os_error() {
Some(32) => return Error::new_ignored(), // Broken pipe
match error {
x if x.kind() == ErrorKind::BrokenPipe => return Error::new_ignored(),
_ => (),
}
Error::new(error.to_string())