Skip to main content

substrate_data/forms/text/
syntax_error.rs

1//! [`SyntaxError`]: what doesn't parse, and where.
2
3use std::fmt;
4
5use super::LineCol;
6
7/// A syntax error.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct SyntaxError {
10    /// What's wrong.
11    pub message: String,
12    /// Its line and column.
13    pub at: LineCol,
14    /// Its byte offset.
15    pub offset: usize,
16}
17
18impl fmt::Display for SyntaxError {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        write!(f, "{}: {}", self.at, self.message)
21    }
22}
23
24impl std::error::Error for SyntaxError {}