Diagnostic
A Diagnostic is the single, transport-agnostic representation of any
error that stackie encounters while loading, parsing, or validating a block
or stack definition. It is produced once — at the failure site — and then
rendered by a DiagnosticRenderer appropriate to the surface in use:
- CLI:
ariadne-based annotated YAML snippets with red underlines (seerender_cli). - API / MCP: JSON
render_json::DiagnosticDto(seerender_json).
Key Types
Diagnostic— the core payload (code, message, YAML buffer, span, hint).DiagnosticCode— exhaustive enum identifying the error category.Severity—ErrororWarning.Span— 1-indexed line/column range within the YAML source.DiagnosticRenderer— trait implemented by each transport.
Example
use stackie::diagnostic::{Diagnostic, DiagnosticCode, Severity, Span};
use std::sync::Arc;
let diag = Diagnostic {
code: DiagnosticCode::E001Parse,
severity: Severity::Error,
message: "unexpected character at line 3".into(),
source_file: None,
yaml: Arc::from("name: postgres\ncommand:\n run: [\n"),
span: Some(Span { start_line: 3, start_col: 8, end_line: 3, end_col: 9 }),
hint: Some("Check the YAML syntax around the opening bracket.".into()),
};