on master help sign in
Fix all compile errors in lib.rs ๐Ÿšš

* Move {controller,output,printer,decorations}.rs into src/bin/ * Add `mod errors` from main.rs

commitcfd33168af2a64f5ae9de22abf3994420ee222ea authorFahmi Akbar Wildana <f.a.wildana@gmail.com> dateSun 6 Oct 2019, 09:10 (7 years ago) parenteefdb18
5 files changed+26โˆ’5
src/controller.rs โ†’ src/bin/controller.rs src/decorations.rs โ†’ src/bin/decorations.rs src/output.rs โ†’ src/bin/output.rs src/printer.rs โ†’ src/bin/printer.rs src/lib.rs+26โˆ’5
src/controller.rs โ†’ src/bin/controller.rsrenamed

The content is the same.

src/decorations.rs โ†’ src/bin/decorations.rsrenamed

The content is the same.

src/output.rs โ†’ src/bin/output.rsrenamed

The content is the same.

src/printer.rs โ†’ src/bin/printer.rsrenamed

The content is the same.

src/lib.rs+26โˆ’5
@@ -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+}