From e6ab276a4d5daaf0dd40eed5e2ff477b48187f77 Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Change return of MacroProcessor to Result --- src/macro_processor/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/macro_processor/main.rs') diff --git a/src/macro_processor/main.rs b/src/macro_processor/main.rs index 247fc85..2d34952 100644 --- a/src/macro_processor/main.rs +++ b/src/macro_processor/main.rs @@ -4,9 +4,17 @@ use std::fs; fn main() { let args: Vec = env::args().collect(); - let input_file = fs::read_to_string(&args[1]).expect("Failed to read input file"); + let input_file = match fs::read_to_string(&args[1]) { + Ok(x) => x, + Err(e) => { + println!("Could not read input-file \"{}\": {}", args[1], e); + std::process::exit(1); + } + }; let mut macro_processor = MacroProcessor::new(); - let final_output = macro_processor.process_input(&input_file); - println!("{}", final_output); + match macro_processor.process_input(&input_file) { + Ok(out) => println!("{}", out), + Err(e) => println!("Error {}", e), + } } -- cgit v1.2.3