Skip to main content

UserFriendlyError

Trait UserFriendlyError 

Source
pub trait UserFriendlyError: Display + Debug {
    // Required methods
    fn user_message(&self) -> String;
    fn developer_message(&self) -> String;
    fn support_code(&self) -> String;
    fn severity(&self) -> ErrorSeverity;

    // Provided methods
    fn suggested_actions(&self) -> Vec<String> { ... }
    fn is_retryable(&self) -> bool { ... }
}
Expand description

Trait providing user-friendly error messaging at multiple levels.

Implementors must supply user-safe text via user_message and richer context for logs and support via developer_message and support_code. The severity, suggested_actions, and is_retryable methods help downstream handling and UX.

This trait is intentionally minimal and does not depend on integration layers, keeping it usable in core/domain code.

Required Methods§

Source

fn user_message(&self) -> String

User-facing message that is clear, actionable, and non-technical.

Guidelines:

  • Plain language any user can understand
  • Actionable guidance when possible
  • Never leak sensitive information
  • Empathetic and helpful tone
Source

fn developer_message(&self) -> String

Technical message with detailed information for developers and logs.

Guidelines:

  • Precise technical details and context for debugging
  • Include relevant identifiers and parameters
  • Structured for parsing by monitoring tools
Source

fn support_code(&self) -> String

Unique support reference code for customer service and troubleshooting.

Guidelines:

  • Unique and easily communicable
  • No sensitive information
  • Consistent across error instances
Source

fn severity(&self) -> ErrorSeverity

Error severity level for proper handling and alerting.

Provided Methods§

Source

fn suggested_actions(&self) -> Vec<String>

Suggested user actions for resolving the error (optional).

Source

fn is_retryable(&self) -> bool

Whether this error should be retryable by the user (default: false).

Implementors§