Improve expect error messages

This commit is contained in:
Paul van Tilburg 2018-03-09 22:25:54 +01:00
parent 95094a7d50
commit 76c0b2f26e
1 changed files with 5 additions and 5 deletions

View File

@ -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),