@@ -23,16 +23,37 @@ extern crate wild;
2323
2424mod assets;
2525mod config;
26โmod controller;
27โmod decorations;
2826mod diff;
2927mod dirs;
3028mod inputfile;
3129mod line_range;
32โmod output;
3330mod preprocessor;
34โmod printer;
3531mod style;
3632mod syntax_mapping;
3733mod terminal;
38โmod util;
34+mod util;
35+
36+mod errors {
37+ error_chain! {
38+ foreign_links {
39+ Clap(::clap::Error);
40+ Io(::std::io::Error);
41+ SyntectError(::syntect::LoadingError);
42+ ParseIntError(::std::num::ParseIntError);
43+ }
44+ }
45+
46+ pub fn handle_error(error: &Error) {
47+ match error {
48+ Error(ErrorKind::Io(ref io_error), _)
49+ if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
50+ {
51+ ::std::process::exit(0);
52+ }
53+ _ => {
54+ use ansi_term::Colour::Red;
55+ eprintln!("{}: {}", Red.paint("[bat error]"), error);
56+ }
57+ };
58+ }
59+}