mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-09-02 20:27:21 +00:00
Merge pull request #72 from benesch/error
Implement std::error::Error for ParserError
This commit is contained in:
commit
bc1ec47e4b
1 changed files with 16 additions and 0 deletions
|
@ -20,6 +20,7 @@ use super::dialect::keywords;
|
||||||
use super::dialect::Dialect;
|
use super::dialect::Dialect;
|
||||||
use super::sqlast::*;
|
use super::sqlast::*;
|
||||||
use super::sqltokenizer::*;
|
use super::sqltokenizer::*;
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum ParserError {
|
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
|
/// SQL Parser
|
||||||
pub struct Parser {
|
pub struct Parser {
|
||||||
tokens: Vec<Token>,
|
tokens: Vec<Token>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue