orrery_parser/error.rs
1//! Error and diagnostic system for the Orrery parser.
2//!
3//! This module provides an error handling system with:
4//! - Error codes for documentation and searchability
5//! - Multiple labeled spans for rich error context
6//! - Severity levels
7//! - Diagnostic collector for accumulating multiple errors
8//!
9//! # Overview
10//!
11//! The error system is built around the [`Diagnostic`] type, which represents
12//! a single error or warning message with optional error code, multiple source
13//! locations, and help text. Multiple diagnostics are wrapped in [`ParseError`]
14//! for returning from the parsing lifecycle.
15//!
16//! # Example
17//!
18//! ```
19//! # use orrery_parser::error::{Diagnostic, ErrorCode};
20//! # use orrery_parser::Span;
21//!
22//! let span = Span::new(100..120);
23//! let original_span = Span::new(50..70);
24//!
25//! let diag = Diagnostic::error("cannot override built-in type `Component`")
26//! .with_code(ErrorCode::E301)
27//! .with_label(span, "type override not supported")
28//! .with_help("built-in types cannot be redefined");
29//! ```
30
31mod collector;
32mod diagnostic;
33mod error_code;
34mod label;
35mod parse_error;
36mod severity;
37mod source_error;
38
39pub(crate) use collector::DiagnosticCollector;
40pub(crate) use parse_error::Result;
41
42pub use diagnostic::Diagnostic;
43pub use error_code::ErrorCode;
44pub use label::Label;
45pub use parse_error::ParseError;
46pub use severity::Severity;
47pub use source_error::SourceError;