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:
committed by
David Peter
parent
e981bd88c1
commit
23d80f9e84
16
src/lib.rs
16
src/lib.rs
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user