Clippy and errors

This commit is contained in:
Sam Hedin 2020-06-25 16:26:33 +02:00
parent a61f0af4c7
commit a631040875
3 changed files with 5 additions and 3 deletions

View File

@ -61,7 +61,8 @@ impl WholeStreamCommand for AutoenvTrust {
.insert(file_to_trust, hasher.finish().to_string());
let config_path = config::default_path_for(&Some(PathBuf::from("nu-env.toml")))?;
fs::write(config_path, toml::to_string(&allowed).unwrap())
let tomlstr = toml::to_string(&allowed).or_else(|_| Err(ShellError::untagged_runtime_error("Couldn't serialize allowed dirs to nu-env.toml")))?;
fs::write(config_path, tomlstr)
.expect("Couldn't write to toml file");
Ok(OutputStream::one(ReturnSuccess::value(

View File

@ -78,7 +78,8 @@ impl WholeStreamCommand for AutoenvUnTrust {
));
}
fs::write(config_path, toml::to_string(&allowed).unwrap())
let tomlstr = toml::to_string(&allowed).or_else(|_| Err(ShellError::untagged_runtime_error("Couldn't serialize allowed dirs to nu-env.toml")))?;
fs::write(config_path, tomlstr)
.expect("Couldn't write to toml file");
Ok(OutputStream::one(ReturnSuccess::value(

View File

@ -43,7 +43,7 @@ impl DirectorySpecificEnvironment {
{
return Ok(content.parse::<toml::Value>().or_else(|_| {
Err(ShellError::untagged_runtime_error(
"Could not parse .nu-env file. Is it well-formed?",
format!("Could not parse {:?}. Is it well-formed?", wdirenv)
))
})?);
}