postgresql_cst_parser/lexer/
parser_error.rs

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