diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-10-11 21:17:48 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-10-12 08:38:07 +0200 |
commit | 27e816fc69f978a26f502aca9f4d824d1e682977 (patch) | |
tree | 458f63d1fda3edbe8c0dbd6522df919c742d0c8d /libimagstore | |
parent | 17fba2c47f6580fdf462d5a5e486b5375f32411e (diff) |
Do not simply unwrap, but return error in case of error
Diffstat (limited to 'libimagstore')
-rw-r--r-- | libimagstore/src/file_abstraction.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libimagstore/src/file_abstraction.rs b/libimagstore/src/file_abstraction.rs index dc04d235..1b9e6790 100644 --- a/libimagstore/src/file_abstraction.rs +++ b/libimagstore/src/file_abstraction.rs @@ -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(()) } |