postgresql_cst_parser/lexer/
parser_error.rs1#[derive(Debug, PartialEq)]
2pub enum ParserError {
3 ParseError {
5 message: String,
6 start_byte_pos: usize,
7 end_byte_pos: usize,
8 },
9 ScanReport(ScanReport),
11 ScanError { message: String },
13}
14
15impl ParserError {
16 pub fn new_report(message: &str, detail: &str, position: usize) -> Self {
17 Self::ScanReport(ScanReport::new(message, detail, position))
18 }
19
20 pub fn new_error(message: &str) -> Self {
21 Self::ScanError {
22 message: message.to_string(),
23 }
24 }
25}
26
27#[derive(Debug, PartialEq)]
28pub struct ScanReport {
29 pub message: String,
30 pub detail: String,
31 pub position_in_bytes: usize,
32}
33
34impl ScanReport {
35 pub fn new(message: &str, detail: &str, position: usize) -> Self {
36 Self {
37 message: message.to_string(),
38 detail: detail.to_string(),
39 position_in_bytes: position,
40 }
41 }
42}