diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-11-06 20:01:53 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-11-06 20:04:47 +0100 |
commit | 44495d6efe6a2daf8f2abcb27bd14e23202de39c (patch) | |
tree | 2bcc954e6dc6fa0c0c1a649a164155dad4d52dda /lib | |
parent | feea57679d678288e066580364e7b0a579c7d1f7 (diff) |
Fix: Do not ignore errors in config anymore
The function already returns `Result<_>`, the only thing that had to be
done was refactoring the code for actually returning an error in that
case.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/core/libimagrt/src/runtime.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 8844afe7..83876ec9 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -388,15 +388,17 @@ impl<'a> Runtime<'a> { self.cli() .value_of("editor") .map(String::from) - .or_else(|| { + .ok_or_else(|| { self.config() - .and_then(|v| match v.read("rt.editor") { - Ok(Some(&Value::String(ref s))) => Some(s.clone()), - _ => None, // FIXME silently ignore errors in config is bad + .ok_or_else(|| Error::from(err_msg("No Configuration!"))) + .and_then(|v| match v.read("rt.editor")? { + Some(&Value::String(ref s)) => Ok(Some(s.clone())), + Some(_) => Err(Error::from(err_msg("Type error at 'rt.editor', expected 'String'"))), + None => Ok(None), }) }) - .or(env::var("EDITOR").ok()) - .ok_or_else(|| Error::from(EM::IO)) + .or(env::var("EDITOR")) + .map_err(|_| Error::from(EM::IO)) .map_dbg(|s| format!("Editing with '{}'", s)) .and_then(|s| { let mut split = s.split_whitespace(); |