round-5 follow-up r2: migrate all thiserror Display attributes to catalog

Completes the i18n sweep started in the previous commit. All
remaining hand-rolled user-facing English strings inside
thiserror #[error(...)] attributes have been moved into the
catalog. Drops the thiserror dependency entirely.

Twelve error types migrated:

- dsl::action::UnknownAction         → parse.custom.unknown_action
- dsl::parser::ParseError            → parse.error_wrapper + parse.empty
- dsl::value::ValueError             → value.{type_mismatch,format}
- persistence::csv_io::CsvError      → persistence.csv.*
- persistence::mod::PersistenceError → persistence.{io,encode}
- persistence::yaml::YamlError       → persistence.yaml.*
- persistence::migrations::MigrateError → persistence.migrate.*
- project::lock::LockError           → project.lock.*
- project::naming::NamingError       → project.naming.*
- project::naming::UserNameError     → project.user_name.*
- project::mod::ProjectError         → project.{path_not_found,...}
- project::mod::SafeDeleteError      → project.safe_delete.*
- archive::ArchiveError              → archive.*
- cli::ArgsError                     → cli.*
- db::DbError                        → db.error.*

Pattern per type: drop thiserror::Error derive, write manual
Display calling crate::t!(), keep #[from] semantics via
explicit From impls, override Error::source() where applicable
so #[source]-style chaining is preserved.

Why this matters (user rationale): "fine to have fallbacks for
errors that are purely technical, but lift the output to a
place where it can be localized later and where an adjustment
with friendly text is easily possible if any of them become
part of the happy path." All surface strings now live in
en-US.yaml and can be reworded or localized without touching
Rust source.

Tests: 769 passing, 0 failed, 1 ignored. Clippy clean with
-D warnings. Cargo.toml: drop thiserror = "2.0.18".
This commit is contained in:
claude@clouddev1
2026-05-13 21:24:51 +00:00
parent 1e06490572
commit 6ca297579e
17 changed files with 680 additions and 117 deletions
+70
View File
@@ -146,9 +146,11 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
("parse.custom.create_table_needs_pk", &[]),
("parse.custom.on_action_specified_twice", &["target"]),
("parse.custom.replay_path_expected", &[]),
("parse.custom.unknown_action", &["found", "expected"]),
("parse.custom.unknown_type", &["found", "expected"]),
("parse.empty", &[]),
("parse.error", &["detail"]),
("parse.error_wrapper", &["detail"]),
// Per-command usage templates (ADR-0021 §1). One key per
// command. Multi-entry families (`add`, `drop`, `show`)
// each have multiple keys. Templates are pure prose with
@@ -253,7 +255,40 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
("project.import_empty_target", &[]),
("project.import_usage", &[]),
("project.import_zip_missing", &["path"]),
("persistence.csv.empty", &[]),
("persistence.csv.invalid_utf8", &[]),
("persistence.csv.unterminated_quote", &[]),
("persistence.encode", &["kind", "path", "message"]),
("persistence.io", &["operation", "path", "source"]),
("persistence.migrate.bad_output", &["detail"]),
("persistence.migrate.io", &["path", "source"]),
(
"persistence.migrate.newer_than_supported",
&["file", "latest"],
),
("persistence.migrate.no_migrator", &["version"]),
("persistence.migrate.step_failed", &["from", "to", "source"]),
("persistence.migrate.version_parse", &["detail"]),
("persistence.yaml.syntax", &["detail"]),
("persistence.yaml.unknown_action", &["raw"]),
("persistence.yaml.unknown_type", &["table", "column", "raw"]),
("persistence.yaml.unsupported_version", &["version"]),
("project.already_exists", &["path"]),
("project.data_root_unavailable", &[]),
("project.io", &["path", "source"]),
("project.load_path_missing", &["path"]),
("project.lock.already_held", &["pid", "hostname", "path"]),
("project.lock.read", &["path", "source"]),
("project.lock.write", &["path", "source"]),
("project.naming.too_many_collisions", &["attempts"]),
("project.naming.wordlist_too_small", &["count"]),
("project.not_a_project", &["path"]),
("project.path_not_found", &["path"]),
("project.safe_delete.io", &["path", "source"]),
("project.safe_delete.refused", &["path", "reason"]),
("project.user_name.empty", &[]),
("project.user_name.invalid_char", &["ch"]),
("project.user_name.leading_dot", &[]),
("project.resume_no_previous", &["data_root"]),
("project.resume_recorded_missing", &["path"]),
("project.saveas_target_exists", &["path"]),
@@ -263,6 +298,25 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
("project.switched_ok", &["display_name"]),
// ---- Advanced-mode placeholder ----
("advanced_mode.not_implemented", &["input"]),
(
"cli.invalid_value",
&["flag", "value", "expected"],
),
("cli.missing_value", &["flag"]),
("cli.multiple_paths", &["first", "second"]),
("cli.resume_with_path", &[]),
("cli.unknown_argument", &["arg"]),
(
"archive.export_sequence_exhausted",
&["project", "target_dir", "limit"],
),
("archive.import_collision_exhausted", &["path", "limit"]),
("archive.invalid_zip", &["detail"]),
("archive.io", &["path", "source"]),
("archive.multiple_top_folders", &[]),
("archive.not_a_project_archive", &[]),
("archive.unsafe_entry", &["entry"]),
("archive.zip", &["path", "message"]),
// ---- DSL failure wrapper / running echo ----
("dsl.failed", &["verb", "subject", "rendered"]),
("dsl.running", &["input"]),
@@ -288,6 +342,8 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
("panel.tables_title", &[]),
("status.no_project", &[]),
("status.project_label", &[]),
("value.format", &["column", "message"]),
("value.type_mismatch", &["column", "expected_human", "got"]),
// ---- Save / save-as surfaces ----
("save.already_saved", &[]),
("save.path_prompt", &[]),
@@ -321,6 +377,20 @@ pub const KEYS_AND_PLACEHOLDERS: &[(&str, &[&str])] = &[
("mode.show_simple", &[]),
("mode.unknown", &["value"]),
("mode.usage", &[]),
// ---- DbError Display fallback ----
("db.error.invalid_value", &["detail"]),
("db.error.io", &["detail"]),
(
"db.error.persistence_fatal",
&["operation", "path", "message"],
),
(
"db.error.rebuild_row_failed",
&["row_number", "csv_path", "table", "detail"],
),
("db.error.sqlite", &["message"]),
("db.error.unsupported", &["detail"]),
("db.error.worker_gone", &[]),
// ---- Cascade-effect summaries (per ADR-0014) ----
("db.cascade.action_blocked", &[]),
("db.cascade.action_deleted", &[]),