no_mistakes_postgres_sql/parse/
error.rs1use sqlparser::parser::ParserError;
2use std::fmt;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct PostgresParseError {
7 pub message: String,
8}
9
10impl fmt::Display for PostgresParseError {
11 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12 f.write_str(&self.message)
13 }
14}
15
16impl std::error::Error for PostgresParseError {}
17
18impl From<ParserError> for PostgresParseError {
19 fn from(error: ParserError) -> Self {
20 let message = match error {
21 ParserError::ParserError(message) | ParserError::TokenizerError(message) => message,
22 ParserError::RecursionLimitExceeded => error.to_string(),
23 };
24 Self { message }
25 }
26}