From a6310408757f2e7220a054514ec6b28ed917c963 Mon Sep 17 00:00:00 2001 From: Sam Hedin Date: Thu, 25 Jun 2020 16:26:33 +0200 Subject: [PATCH] Clippy and errors --- crates/nu-cli/src/commands/autoenv_trust.rs | 3 ++- crates/nu-cli/src/commands/autoenv_untrust.rs | 3 ++- crates/nu-cli/src/env/directory_specific_environment.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/nu-cli/src/commands/autoenv_trust.rs b/crates/nu-cli/src/commands/autoenv_trust.rs index c905b2da13..73afb1c059 100644 --- a/crates/nu-cli/src/commands/autoenv_trust.rs +++ b/crates/nu-cli/src/commands/autoenv_trust.rs @@ -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( diff --git a/crates/nu-cli/src/commands/autoenv_untrust.rs b/crates/nu-cli/src/commands/autoenv_untrust.rs index 07aa3abb74..fafd19c9ee 100644 --- a/crates/nu-cli/src/commands/autoenv_untrust.rs +++ b/crates/nu-cli/src/commands/autoenv_untrust.rs @@ -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( diff --git a/crates/nu-cli/src/env/directory_specific_environment.rs b/crates/nu-cli/src/env/directory_specific_environment.rs index 1508277a98..b362f1c24e 100644 --- a/crates/nu-cli/src/env/directory_specific_environment.rs +++ b/crates/nu-cli/src/env/directory_specific_environment.rs @@ -43,7 +43,7 @@ impl DirectorySpecificEnvironment { { return Ok(content.parse::().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) )) })?); }