From 44495d6efe6a2daf8f2abcb27bd14e23202de39c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 6 Nov 2018 20:01:53 +0100 Subject: 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 --- lib/core/libimagrt/src/runtime.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/core/libimagrt') 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(); -- cgit v1.2.3