mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 17:14:27 +02:00
Replace match with or_else
This commit is contained in:
parent
b9c170d359
commit
ce23b3b96e
@ -22,19 +22,16 @@ impl Trusted {
|
|||||||
pub fn read_trusted() -> Result<Self, ShellError> {
|
pub fn read_trusted() -> Result<Self, ShellError> {
|
||||||
let config_path = config::default_path_for(&Some(PathBuf::from("nu-env.toml")))?;
|
let config_path = config::default_path_for(&Some(PathBuf::from("nu-env.toml")))?;
|
||||||
|
|
||||||
let mut file = match std::fs::OpenOptions::new()
|
let mut file = std::fs::OpenOptions::new()
|
||||||
.read(true)
|
.read(true)
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(config_path)
|
.open(config_path)
|
||||||
{
|
.or_else(|_| {
|
||||||
Ok(p) => p,
|
Err(ShellError::untagged_runtime_error(
|
||||||
Err(_) => {
|
|
||||||
return Err(ShellError::untagged_runtime_error(
|
|
||||||
"Couldn't open nu-env.toml",
|
"Couldn't open nu-env.toml",
|
||||||
));
|
))
|
||||||
}
|
})?;
|
||||||
};
|
|
||||||
let mut doc = String::new();
|
let mut doc = String::new();
|
||||||
file.read_to_string(&mut doc)?;
|
file.read_to_string(&mut doc)?;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl DirectorySpecificEnvironment {
|
|||||||
})?);
|
})?);
|
||||||
}
|
}
|
||||||
return Err(ShellError::untagged_runtime_error(
|
return Err(ShellError::untagged_runtime_error(
|
||||||
format!("{:?} is untrusted. Run 'autoenv trust {:?}' and restart nushell to trust it.\nThis needs to be done after each change to the file.\n", wdirenv, wdirenv.parent().unwrap_or_else(|| &Path::new("")))));
|
format!("{:?} is untrusted. Run 'autoenv trust {:?}' and restart nushell to trust it.\nThis needs to be done after each change to the file.", wdirenv, wdirenv.parent().unwrap_or_else(|| &Path::new("")))));
|
||||||
}
|
}
|
||||||
Err(ShellError::untagged_runtime_error("No trusted directories"))
|
Err(ShellError::untagged_runtime_error("No trusted directories"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user