2020-03-21 19:35:04 +01:00
|
|
|
use error_chain::error_chain;
|
|
|
|
|
|
|
|
error_chain! {
|
|
|
|
foreign_links {
|
|
|
|
Clap(::clap::Error);
|
|
|
|
Io(::std::io::Error);
|
|
|
|
SyntectError(::syntect::LoadingError);
|
|
|
|
ParseIntError(::std::num::ParseIntError);
|
2020-03-22 09:55:13 +01:00
|
|
|
GlobParsingError(::globset::Error);
|
2020-03-21 19:35:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-21 19:51:59 +01:00
|
|
|
pub fn default_error_handler(error: &Error) {
|
2020-03-21 19:35:04 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|