diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-05-25 19:32:51 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-05-25 19:32:51 -0400 |
commit | ea7460794a01a5b8e8ca216389d730f0693ff4ea (patch) | |
tree | 7536369a0f2a23cd209f1459cbb1d9b214c352be /src/bin | |
parent | 6e57cb466f2ccd7b0eb4de216f45d3eddfcb3665 (diff) | |
download | rbw-ea7460794a01a5b8e8ca216389d730f0693ff4ea.tar.gz rbw-ea7460794a01a5b8e8ca216389d730f0693ff4ea.zip |
remove some redundant error contexts
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/rbw/commands.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs index 0213962..ac27755 100644 --- a/src/bin/rbw/commands.rs +++ b/src/bin/rbw/commands.rs @@ -310,8 +310,7 @@ const HELP: &str = r#" "#; pub fn config_show() -> anyhow::Result<()> { - let config = - rbw::config::Config::load().context("failed to load config")?; + let config = rbw::config::Config::load()?; serde_json::to_writer_pretty(std::io::stdout(), &config) .context("failed to write config to stdout")?; println!(); @@ -338,7 +337,7 @@ pub fn config_set(key: &str, value: &str) -> anyhow::Result<()> { } _ => return Err(anyhow::anyhow!("invalid config key: {}", key)), } - config.save().context("failed to save config file")?; + config.save()?; // drop in-memory keys, since they will be different if the email or url // changed. not using lock() because we don't want to require the agent to @@ -362,7 +361,7 @@ pub fn config_unset(key: &str) -> anyhow::Result<()> { } _ => return Err(anyhow::anyhow!("invalid config key: {}", key)), } - config.save().context("failed to save config file")?; + config.save()?; // drop in-memory keys, since they will be different if the email or url // changed. not using lock() because we don't want to require the agent to @@ -1201,7 +1200,7 @@ fn load_db() -> anyhow::Result<rbw::db::Db> { let config = rbw::config::Config::load()?; if let Some(email) = &config.email { rbw::db::Db::load(&config.server_name(), &email) - .context("failed to load password database") + .map_err(anyhow::Error::new) } else { Err(anyhow::anyhow!("failed to find email address in config")) } @@ -1211,7 +1210,7 @@ fn save_db(db: &rbw::db::Db) -> anyhow::Result<()> { let config = rbw::config::Config::load()?; if let Some(email) = &config.email { db.save(&config.server_name(), &email) - .context("failed to save password database") + .map_err(anyhow::Error::new) } else { Err(anyhow::anyhow!("failed to find email address in config")) } @@ -1221,7 +1220,7 @@ fn remove_db() -> anyhow::Result<()> { let config = rbw::config::Config::load()?; if let Some(email) = &config.email { rbw::db::Db::remove(&config.server_name(), &email) - .context("failed to remove password database") + .map_err(anyhow::Error::new) } else { Err(anyhow::anyhow!("failed to find email address in config")) } |