Registry / RepositoryTypeScriptRustPython
Rollpie
ReadmeFiles
Versions
Info
Download
0.2.3555.5 KB2026-10-160.2.2572.8 KB2026-10-150.2.1580.5 KB2026-10-150.2.0579.9 KB2026-09-150.1.1576.6 KB2026-09-12
Version
0.2.2
Copyright
Rollpie, Irohabook
Publisher
math
Published
2026-10-15
Size
572.8 KB
Downloads
28
Checksum
ce26f898ba26eb49c71ebc68597f62f268b83e41bb265b1b5a01688966054588
Dependencies
None

error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! The error returned when parsing fails

use std::fmt;


/// The reason parsing failed, and its position in the source string
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Error {
    /// A description of what happened
    pub message: String,
    /// The character position counted from the start of the source string (0-based)
    pub position: usize,
}


impl Error {
    pub fn new(message: impl Into<String>, position: usize) -> Error {
        Error {message: message.into(), position}
    }
}


impl fmt::Display for Error {
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        write!(formatter, "{} (at character {})", self.message, self.position + 1)
    }
}


impl std::error::Error for Error {}