1
Fork 0

Return a more verbose error when formatting a file fails

Expands the error message returned if the after_file function fails to
also include path_str. This allows users to better identify files that are
not being formatted.
This commit is contained in:
Bryce Van Dyk 2017-10-19 22:52:12 +13:00
parent 560b054147
commit 47a0bef91c

View file

@ -325,7 +325,14 @@ where
}
visitor.format_separate_mod(module, &*filemap);
has_diff |= after_file(path_str, &mut visitor.buffer)?;
has_diff |= match after_file(path_str, &mut visitor.buffer) {
Ok(result) => result,
Err(e) => {
// Create a new error with path_str to help users see which files failed
let mut err_msg = path_str.to_string() + &": ".to_string() + &e.to_string();
return Err(io::Error::new(e.kind(), err_msg));
}
};
result.push((path_str.to_owned(), visitor.buffer));
}