Skip to content

Commit adbe98e

Browse files
authored
Merge pull request #2069 from SingingTree/log_path_str_if_after_file_errors
Return a more verbose error when formatting a file fails
2 parents 4386fc2 + 47a0bef commit adbe98e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,14 @@ where
329329
visitor.format_separate_mod(module, &*filemap);
330330
};
331331

332-
has_diff |= after_file(path_str, &mut visitor.buffer)?;
332+
has_diff |= match after_file(path_str, &mut visitor.buffer) {
333+
Ok(result) => result,
334+
Err(e) => {
335+
// Create a new error with path_str to help users see which files failed
336+
let mut err_msg = path_str.to_string() + &": ".to_string() + &e.to_string();
337+
return Err(io::Error::new(e.kind(), err_msg));
338+
}
339+
};
333340

334341
result.push((path_str.to_owned(), visitor.buffer));
335342
}

0 commit comments

Comments
 (0)