summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f8359055..9ee612fe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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