basic error handling
This commit is contained in:
parent
ea61afade2
commit
fcd70e2c4e
1 changed files with 8 additions and 4 deletions
12
src/main.rs
12
src/main.rs
|
@ -6,8 +6,12 @@ struct Cli {
|
|||
path: std::path::PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Cli::parse();
|
||||
|
||||
println!("pattern: {:?}, path: {:?}", args.pattern, args.path);
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let result = std::fs::read_to_string("test.txt");
|
||||
let content = match result {
|
||||
Ok(content) => { content },
|
||||
Err(error) => { return Err(error.into()); },
|
||||
};
|
||||
println!("file content: {}", content);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue