rill_json/
error.rs

1//! Contains the primary `ParseError` type for the library.
2use std::fmt;
3
4/// The primary error type for all parsing operations.
5///
6/// This struct contains a human-readable error message and the
7/// location (line and column) where the error occurred.
8#[derive(Debug, PartialEq)]
9pub struct ParseError {
10    /// A description of what went wrong.
11    pub message: String,
12    /// The line number (1-indexed) where the error was detected.
13    pub line: usize,
14    /// The column number (1-indexed) where the error was detected.
15    pub column: usize,
16}
17
18// --- Error Formatting ---
19// This provides a user-friendly, human-readable error message.
20impl fmt::Display for ParseError {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        write!(
23            f,
24            "Error: {} at line {}, column {}.",
25            self.message, self.line, self.column
26        )
27    }
28}