diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 31 |
1 files changed, 26 insertions, 5 deletions
@@ -23,16 +23,37 @@ extern crate wild; mod assets; mod config; -mod controller; -mod decorations; mod diff; mod dirs; mod inputfile; mod line_range; -mod output; mod preprocessor; -mod printer; mod style; mod syntax_mapping; mod terminal; -mod util;
\ No newline at end of file +mod util; + +mod errors { + error_chain! { + foreign_links { + Clap(::clap::Error); + Io(::std::io::Error); + SyntectError(::syntect::LoadingError); + 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); + } + }; + } +}
\ No newline at end of file |