use csv;
use std::io;
error_chain! {
foreign_links {
Csv(csv::Error);
Io(io::Error);
}
errors {
TooManyBadRows(bad: u64, total: u64) {
description("a large portion of your rows were bad")
display("a large portion of your rows ({} of {}) were bad", bad, total)
}
}
}
impl Error {
pub fn should_show_backtrace(&self) -> bool {
match *self.kind() {
ErrorKind::TooManyBadRows(_, _) => false,
_ => true,
}
}
pub fn to_exit_code(&self) -> i32 {
match *self.kind() {
ErrorKind::TooManyBadRows(_, _) => 2,
_ => 1,
}
}
}