From ff4f80c2c0ffdc90a967f8b8a6e67171971d4fb8 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 6 Jun 2025 16:15:51 +0200 Subject: [PATCH] Improved error handling --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 98843e3..f591749 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 {