mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 14:28:22 +00:00
Implement std::error::Error for ParserError
This commit is contained in:
parent
4f944dd4aa
commit
373a9265a2
1 changed files with 16 additions and 0 deletions
|
@ -20,6 +20,7 @@ use super::dialect::keywords;
|
|||
use super::dialect::Dialect;
|
||||
use super::sqlast::*;
|
||||
use super::sqltokenizer::*;
|
||||
use std::error::Error;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum ParserError {
|
||||
|
@ -47,6 +48,21 @@ impl From<TokenizerError> for ParserError {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ParserError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"sql parser error: {}",
|
||||
match self {
|
||||
ParserError::TokenizerError(s) => s,
|
||||
ParserError::ParserError(s) => s,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for ParserError {}
|
||||
|
||||
/// SQL Parser
|
||||
pub struct Parser {
|
||||
tokens: Vec<Token>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue