Improve expect error messages
This commit is contained in:
parent
95094a7d50
commit
76c0b2f26e
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue