diff --git a/cli/src/config.rs b/cli/src/config.rs index eb79e8c74b..98843a5473 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -493,11 +493,11 @@ pub fn remove_config_value_from_file( let target_table = key_iter.try_fold(doc.as_table_mut(), |table, key| { table .get_mut(key) - .ok_or_else(|| ConfigError::NotFound(key.to_string())) + .ok_or_else(|| user_error(format!(r#""{key}" doesn't exist"#))) .and_then(|table| { table .as_table_mut() - .ok_or_else(|| ConfigError::Message(format!(r#""{key}" is not a table"#))) + .ok_or_else(|| user_error(format!(r#""{key}" is not a table"#))) }) })?; @@ -510,7 +510,7 @@ pub fn remove_config_value_from_file( entry.remove(); } toml_edit::Entry::Vacant(_) => { - return Err(ConfigError::NotFound(key.to_string()).into()); + return Err(user_error(format!(r#""{key}" doesn't exist"#))); } } diff --git a/cli/tests/test_config_command.rs b/cli/tests/test_config_command.rs index 860a31b7c4..0284b0e5eb 100644 --- a/cli/tests/test_config_command.rs +++ b/cli/tests/test_config_command.rs @@ -613,10 +613,7 @@ fn test_config_unset_non_existent_key() { let repo_path = test_env.env_root().join("repo"); let stderr = test_env.jj_cmd_failure(&repo_path, &["config", "unset", "--user", "nonexistent"]); - insta::assert_snapshot!(stderr, @r###" - Config error: configuration property "nonexistent" not found - For help, see https://martinvonz.github.io/jj/latest/config/. - "###); + insta::assert_snapshot!(stderr, @r#"Error: "nonexistent" doesn't exist"#); } #[test] @@ -637,10 +634,7 @@ fn test_config_unset_inline_table_key() { &["config", "unset", "--user", "inline-table.foo"], ); - insta::assert_snapshot!(stderr, @r###" - Config error: "inline-table" is not a table - For help, see https://martinvonz.github.io/jj/latest/config/. - "###); + insta::assert_snapshot!(stderr, @r#"Error: "inline-table" is not a table"#); } #[test]