1
0
mirror of https://github.com/sharkdp/bat synced 2026-07-18 16:13:22 +00:00
Files
sharkdp--bat/src/errors.rs
T
sharkdp 72618db179 Add metadata information to cached assets
When saving/reading user-provided syntaxes or themes, `bat` will now maintain a
`metadata.yaml` file which includes information about the `bat` version which was
used to create the cached files. When loading cached files, we now print an error
if they have been created with an incompatible version

closes #882
2020-04-21 18:14:31 +02:00

35 lines
952 B
Rust

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);
}
};
}