refactor(CommandParseError): remove the display implementation

we want to be able to give additional arguments to the display function later,
so this is needed
This commit is contained in:
Khaïs COLIN 2025-05-04 13:43:05 +02:00
parent b8ed0868cb
commit 55b4779964
4 changed files with 33 additions and 11 deletions

View file

@ -54,16 +54,12 @@ pub enum CommandParseError {
Scan(ScanError),
}
impl std::fmt::Display for CommandParseError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
impl CommandParseError {
pub(crate) fn message(&self) -> String {
match self {
CommandParseError::MetaCommand(meta_command_parse_error) => {
write!(f, "{meta_command_parse_error}")
}
CommandParseError::Statement(statement_parse_error) => {
write!(f, "{statement_parse_error}")
}
CommandParseError::Scan(scan_error) => write!(f, "{scan_error:?}"),
CommandParseError::MetaCommand(x) => format!("{x}"),
CommandParseError::Statement(x) => format!("{x}"),
CommandParseError::Scan(x) => format!("{x}"),
}
}
}