postgresql_cst_parser/lexer/
parser_error.rs

1#[derive(Debug, PartialEq)]
2pub enum ParserError {
3    /// SQL syntax error
4    ParseError {
5        message: String,
6        start_byte_pos: usize,
7        end_byte_pos: usize,
8    },
9    /// Error raised by ereport
10    ScanReport(ScanReport),
11    /// Error raised by yyerror
12    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}