mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-04 20:32:27 +01:00
Rename error module
This commit is contained in:
34
src/error.rs
Normal file
34
src/error.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use error_chain::error_chain;
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
Clap(::clap::Error) #[cfg(feature = "application")];
|
||||
Io(::std::io::Error);
|
||||
SyntectError(::syntect::LoadingError);
|
||||
ParseIntError(::std::num::ParseIntError);
|
||||
GlobParsingError(::globset::Error);
|
||||
SerdeYamlError(::serde_yaml::Error);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn default_error_handler(error: &Error) {
|
||||
use ansi_term::Colour::Red;
|
||||
|
||||
match error {
|
||||
Error(ErrorKind::Io(ref io_error), _)
|
||||
if io_error.kind() == ::std::io::ErrorKind::BrokenPipe =>
|
||||
{
|
||||
::std::process::exit(0);
|
||||
}
|
||||
Error(ErrorKind::SerdeYamlError(_), _) => {
|
||||
eprintln!(
|
||||
"{}: Error while parsing metadata.yaml file: {}",
|
||||
Red.paint("[bat error]"),
|
||||
error
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
eprintln!("{}: {}", Red.paint("[bat error]"), error);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user