mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-04 09:53:04 +03:00
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:
+8
-1
@@ -325,7 +325,14 @@ fn format_ast<F>(
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user