Do not simply unwrap, but return error in case of error
This commit is contained in:
parent
17fba2c47f
commit
27e816fc69
1 changed files with 2 additions and 2 deletions
|
@ -69,14 +69,14 @@ mod fs {
|
|||
|
||||
pub fn copy(from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
|
||||
let mut map = MAP.lock().unwrap();
|
||||
let a = map.get(from).unwrap().clone();
|
||||
let a = try!(map.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
|
||||
map.insert(to.clone(), a);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn rename(from: &PathBuf, to: &PathBuf) -> Result<(), SE> {
|
||||
let mut map = MAP.lock().unwrap();
|
||||
let a = map.get(from).unwrap().clone();
|
||||
let a = try!(map.get(from).cloned().ok_or(SEK::FileNotFound.into_error()));
|
||||
map.insert(to.clone(), a);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue