Skip to main content

fabula_dsl/
error.rs

1//! Parse error types with source location tracking.
2
3use std::fmt;
4
5/// A parse error with source location information.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct ParseError {
8    /// 1-based line number where the error occurred.
9    pub line: usize,
10    /// 1-based column number where the error occurred.
11    pub column: usize,
12    /// Byte offset range `(start, end)` in the source text.
13    pub span: (usize, usize),
14    /// Human-readable error message.
15    pub message: String,
16}
17
18impl fmt::Display for ParseError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        write!(f, "{}:{}: {}", self.line, self.column, self.message)
21    }
22}
23
24impl std::error::Error for ParseError {}