use std::env;
use std::fs;
mod custom_error;
use custom_error::CustomError;
fn main() {
let res = read_file();
match res {
Err(err) => println!("{:?}", err.0),
Ok(content) => println!("{}", content),
}
}
fn read_file() -> Result<String, CustomError> {
println!("read file");
let file_path = env::args().skip(1).next().unwrap(); println!("file_path:{}", file_path);
let content = fs::read_to_string(file_path)
.map_err(|err| CustomError(format!("read file err:{}", err)))?;
Ok(content)
}