diff --git a/src/controller.rs b/src/bin/controller.rs similarity index 100% rename from src/controller.rs rename to src/bin/controller.rs diff --git a/src/decorations.rs b/src/bin/decorations.rs similarity index 100% rename from src/decorations.rs rename to src/bin/decorations.rs diff --git a/src/output.rs b/src/bin/output.rs similarity index 100% rename from src/output.rs rename to src/bin/output.rs diff --git a/src/printer.rs b/src/bin/printer.rs similarity index 100% rename from src/printer.rs rename to src/bin/printer.rs 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