diff options
author | Fahmi Akbar Wildana <f.a.wildana@gmail.com> | 2019-10-06 09:10:03 +0700 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2019-10-20 21:43:51 +0200 |
commit | cfd33168af2a64f5ae9de22abf3994420ee222ea (patch) | |
tree | f07af4824fd81173a2e2ee105d1c435f59b95e51 | |
parent | eefdb186b8f05aedfa5ca76c89a4d14bebbfac32 (diff) |
Fix all compile errors in lib.rs 🚚
* Move {controller,output,printer,decorations}.rs into src/bin/
* Add `mod errors` from main.rs
-rw-r--r-- | src/bin/controller.rs (renamed from src/controller.rs) | 0 | ||||
-rw-r--r-- | src/bin/decorations.rs (renamed from src/decorations.rs) | 0 | ||||
-rw-r--r-- | src/bin/output.rs (renamed from src/output.rs) | 0 | ||||
-rw-r--r-- | src/bin/printer.rs (renamed from src/printer.rs) | 0 | ||||
-rw-r--r-- | src/lib.rs | 31 |
5 files changed, 26 insertions, 5 deletions
diff --git a/src/controller.rs b/src/bin/controller.rs index b67d03c5..b67d03c5 100644 --- a/src/controller.rs +++ b/src/bin/controller.rs diff --git a/src/decorations.rs b/src/bin/decorations.rs index 7654c617..7654c617 100644 --- a/src/decorations.rs +++ b/src/bin/decorations.rs diff --git a/src/output.rs b/src/bin/output.rs index e0b567a6..e0b567a6 100644 --- a/src/output.rs +++ b/src/bin/output.rs diff --git a/src/printer.rs b/src/bin/printer.rs index 8da7af93..8da7af93 100644 --- a/src/printer.rs +++ b/src/bin/printer.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 |