basic error handling

This commit is contained in:
Fabio Montefuscolo 2025-04-01 22:02:19 +02:00
parent ea61afade2
commit fcd70e2c4e
Signed by: fabiomontefuscolo
GPG key ID: 7598676DAE19B4EF

View file

@ -6,8 +6,12 @@ struct Cli {
path: std::path::PathBuf, path: std::path::PathBuf,
} }
fn main() { fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Cli::parse(); let result = std::fs::read_to_string("test.txt");
let content = match result {
println!("pattern: {:?}, path: {:?}", args.pattern, args.path); Ok(content) => { content },
Err(error) => { return Err(error.into()); },
};
println!("file content: {}", content);
Ok(())
} }