Use return value: fail if content could not be read

This commit is contained in:
Matthias Beyer 2016-01-05 16:05:59 +01:00
parent ff281e4334
commit c380e0f64f

View file

@ -101,7 +101,11 @@ pub fn edit_content(rt: &Runtime, old_content: String) -> (String, bool) {
let mut contents = String::new();
File::open(filepath).map(|mut file| {
file.read_to_string(&mut contents);
file.read_to_string(&mut contents).map_err(|e| {
error!("Error reading content: {}", e);
debug!("Error reading content: {:?}", e);
exit(1);
}).is_ok();
(contents, true)
}).unwrap_or((old_content, false))
}