feat(CommandParseError): add ScanError variand with Into impl
This commit is contained in:
parent
cbc4a4755c
commit
b8ed0868cb
2 changed files with 13 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use crate::meta_commands::{MetaCommand, MetaCommandExecuteResult, MetaCommandParseError};
|
||||
use crate::statements::{Statement, StatementExecuteResult, StatementParseError};
|
||||
use crate::tokens::ScanError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Command {
|
||||
|
|
@ -50,6 +51,7 @@ impl Command {
|
|||
pub enum CommandParseError {
|
||||
MetaCommand(MetaCommandParseError),
|
||||
Statement(StatementParseError),
|
||||
Scan(ScanError),
|
||||
}
|
||||
|
||||
impl std::fmt::Display for CommandParseError {
|
||||
|
|
@ -61,6 +63,7 @@ impl std::fmt::Display for CommandParseError {
|
|||
CommandParseError::Statement(statement_parse_error) => {
|
||||
write!(f, "{statement_parse_error}")
|
||||
}
|
||||
CommandParseError::Scan(scan_error) => write!(f, "{scan_error:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -89,6 +92,12 @@ impl From<StatementParseError> for CommandParseError {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<ScanError> for CommandParseError {
|
||||
fn from(value: ScanError) -> Self {
|
||||
CommandParseError::Scan(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Command {
|
||||
type Err = CommandParseError;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue