From d1fdebb68c2818b224b092d4c265394f3fbdcb5d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 7 May 2019 22:55:08 +0200 Subject: Handle missing phishtank file. --- src/main.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4e3076b..17f443b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,10 +30,15 @@ fn main() { ).get_matches(); let start_time = SystemTime::now(); - let r = BufReader::new(File::open(args.value_of("PHISHTANK").unwrap()).unwrap()); - let tank = phisher::load_phistank(r).unwrap(); + let filename = args.value_of("PHISHTANK").unwrap(); + if let Ok(file) = File::open(filename) { + let tank = phisher::load_phistank(BufReader::new(file)).unwrap(); - println!("Loaded {} phishes in {} seconds!", - tank.phishes.len(), - start_time.elapsed().unwrap().as_secs()); + println!("Loaded {} phishes in {} seconds!", + tank.phishes.len(), + start_time.elapsed().unwrap().as_secs()); + } + else { + eprintln!("Could not open file {}.\nIs the filename correct?", filename); + } } -- cgit v1.2.3