mirror of
https://github.com/nushell/nushell.git
synced 2025-05-02 09:04:30 +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> {
|
||||
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)
|
||||
.create(true)
|
||||
.write(true)
|
||||
.open(config_path)
|
||||
{
|
||||
Ok(p) => p,
|
||||
Err(_) => {
|
||||
return Err(ShellError::untagged_runtime_error(
|
||||
.or_else(|_| {
|
||||
Err(ShellError::untagged_runtime_error(
|
||||
"Couldn't open nu-env.toml",
|
||||
));
|
||||
}
|
||||
};
|
||||
))
|
||||
})?;
|
||||
let mut doc = String::new();
|
||||
file.read_to_string(&mut doc)?;
|
||||
|
||||
|
@ -49,7 +49,7 @@ impl DirectorySpecificEnvironment {
|
||||
})?);
|
||||
}
|
||||
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"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user