1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

Fix all compile errors in bin/bat

* Change `mod errors` in lib.rs to public

* Add `fn handle_error` in lib.rs errors module
This commit is contained in:
Fahmi Akbar Wildana
2019-10-06 09:10:03 +07:00
committed by David Peter
parent e981bd88c1
commit 23d80f9e84
7 changed files with 64 additions and 72 deletions

View File

@@ -30,7 +30,7 @@ pub mod syntax_mapping;
pub mod terminal;
pub mod util;
mod errors {
pub mod errors {
error_chain! {
foreign_links {
Clap(::clap::Error);
@@ -39,4 +39,18 @@ mod errors {
ParseIntError(::std::num::ParseIntError);
}
}
pub fn handle_error(error: &Error) {
match error {
Error(ErrorKind::Io(ref io_error), _)
if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
{
::std::process::exit(0);
}
_ => {
use ansi_term::Colour::Red;
eprintln!("{}: {}", Red.paint("[bat error]"), error);
}
};
}
}