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
|
|
@ -145,10 +145,13 @@ CLOCK: [2025-05-04 dim. 13:32]--[2025-05-04 dim. 13:35] => 0:03
|
|||
CLOCK: [2025-05-04 dim. 13:27]--[2025-05-04 dim. 13:32] => 0:05
|
||||
:END:
|
||||
|
||||
*** TODO CommandParseError must have a ScanError variant with an Into impl
|
||||
*** DONE CommandParseError must have a ScanError variant with an Into impl
|
||||
:PROPERTIES:
|
||||
:EFFORT: 10
|
||||
:END:
|
||||
:LOGBOOK:
|
||||
CLOCK: [2025-05-04 dim. 13:35]--[2025-05-04 dim. 13:38] => 0:03
|
||||
:END:
|
||||
|
||||
*** TODO ScanErrors must be convertible to ariadne reports
|
||||
:PROPERTIES:
|
||||
|
|
|
|||
|
|
@ -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