1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-03 18:51:44 +00:00

Move error module to separate file

This commit is contained in:
sharkdp
2020-03-21 19:35:04 +01:00
committed by David Peter
parent fedd32173e
commit 7e0115641d
3 changed files with 35 additions and 32 deletions
+24
View File
@@ -0,0 +1,24 @@
use error_chain::error_chain;
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);
}
};
}