Skip to main content

localized_error_text

Function localized_error_text 

Source
pub fn localized_error_text(err: &SshCliError) -> Option<String>
Expand description

Renders a domain error in the operator’s language, for human output only.

§Why this exists (B2)

Six Error* variants shipped with full English and Brazilian Portuguese translations and never had a single call site: every failure reached the user through thiserror’s #[error("…")] attribute literal instead, so --lang pt-BR produced byte-identical English output. This is the seam that makes the translations reachable.

§Contract boundary

This is not used for the --json envelope. There, message stays the English std::fmt::Display of SshCliError by contract: agents branch on the stable error_code discriminator, and a locale-dependent message would silently change the payload an agent parses when the host locale changes.

Returns None for any error code without a translation, so the caller falls back to the English Display. That fail-open shape means adding a new SshCliError variant can never blank out the human error line.