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>
This commit is contained in:
parent
feea57679d
commit
44495d6efe
1 changed files with 8 additions and 6 deletions
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue