Improved error handling
All checks were successful
/ test (push) Successful in 12s

This commit is contained in:
Eduard Urbach 2025-06-06 16:15:51 +02:00
parent 75a0c21c01
commit ff4f80c2c0
Signed by: eduard
GPG key ID: 49226B848C78F6C8

View file

@ -20,7 +20,13 @@ fn main() {
}
fn process_file(path: &str, mode: &Mode) {
let mut content = fs::read_to_string(path).expect("could not read file");
let mut content = match fs::read_to_string(path) {
Ok(content) => { content },
Err(error) => {
println!("\x1B[1m{}\x1B[0m: {}", path, error);
return;
}
};
if ends_with_newline(&content) {
match mode {