1use crate::error::SuchError::{Denied, LikeNotPossible, ParseError};
2use crate::suchbar::Rule;
3use std::fmt::{Display, Formatter};
4
5#[derive(Debug)]
6pub enum SuchError {
7 ParseError(String),
8 LikeNotPossible,
9 Denied,
10}
11
12impl From<pest::error::Error<Rule>> for SuchError {
13 fn from(value: pest::error::Error<Rule>) -> Self {
14 ParseError(value.to_string())
15 }
16}
17
18impl Display for SuchError {
19 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20 match self {
21 ParseError(str) => write!(f, "{str}"),
22 LikeNotPossible => write!(f, "LIKE not possible"),
23 Denied => write!(f, "DENIED"),
24 }
25 }
26}
27
28impl From<timewarp::TimeWarpError> for SuchError {
29 fn from(value: timewarp::TimeWarpError) -> Self {
30 ParseError(value.to_string())
31 }
32}