Expand description
Translates raw technical errors into beginner-friendly advice.
translate_error takes a DiagnosticResult (or a raw error surfaced
as one) and turns it into a MentorMessage: the raw error is kept as
technical_detail, while plain_english explains it in everyday terms —
often with an analogy — and suggested_action gives a concrete next step.
The translation database lives in TRANSLATIONS and covers 50+ common
Node.js, Python, Rust and port/system errors. Patterns are matched with a
simple case-insensitive substring check (OR across each entry’s
needles), so the same error from different tools can share one entry.
§Example
use limitless_cli::models::{CheckStatus, DiagnosticResult, Severity};
use limitless_cli::modules::translator::translate_error;
let port_error = DiagnosticResult::new(
"Server",
CheckStatus::Fail,
"Error: EADDRINUSE: address already in use :::3000",
);
let mentor = translate_error(&port_error);
assert_eq!(mentor.severity, Severity::Warning);
assert!(mentor.plain_english.contains("3000"));
assert!(mentor.technical_detail.contains("EADDRINUSE"));
assert!(mentor.suggested_action.contains("3000"));Structs§
- Translation
Entry - A single translation entry.
Enums§
- Category
- Which ecosystem an error belongs to.
Constants§
- TRANSLATIONS
- The full translation database (> 50 entries). Order matters: earlier entries win when several could match.
Functions§
- explain_
error - translate_
error - Translates a
DiagnosticResultinto a beginner-friendlyMentorMessage. - translate_
issue - translations_
for - Looks up translator database entries by category (used for coverage tests).