From 76c0b2f26e1602762d79d083a590004a11886af2 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 9 Mar 2018 22:25:54 +0100 Subject: [PATCH] Improve expect error messages --- src/models/note.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/models/note.rs b/src/models/note.rs index 288b4db..56384a9 100644 --- a/src/models/note.rs +++ b/src/models/note.rs @@ -36,11 +36,11 @@ impl Note { pub fn update_data(&mut self, data: &String) { let mut file = File::create(&self.path).expect(&format!( - "Cannot open note file {}", + "Cannot open note file: {}", self.path.to_str().unwrap() )); file.write_all(data.as_bytes()).expect(&format!( - "Cannot write note file {}", + "Cannot write note file: {}", self.path.to_str().unwrap() )); @@ -64,11 +64,11 @@ impl Note { }; let mut data = String::new(); let mut file = - File::open(&entry).expect(&format!("Cannot open note file {}", file_name)); + File::open(&entry).expect(&format!("Cannot open note file: {}", file_name)); file.read_to_string(&mut data) - .expect(&format!("Cannot read note file {}", file_name)); + .expect(&format!("Cannot read note file: {}", file_name)); let metadata = file.metadata() - .expect(&format!("Cannot get metadata of note file {}", file_name)); + .expect(&format!("Cannot get metadata of note file: {}", file_name)); let mut note = Note { id: String::from(name),