use std::sync::PoisonError; use chumsky::prelude::Rich; use crate::lexer::Token; #[derive(Debug, PartialEq)] pub enum Error<'src> { Parse(Vec>>), Lex(Vec>), Runtime(RuntimeError), } impl<'src> From>>> for Error<'src> { fn from(errors: Vec>>) -> Self { Error::Parse(errors) } } impl<'src> From>> for Error<'src> { fn from(errors: Vec>) -> Self { Error::Lex(errors) } } impl<'src> From for Error<'src> { fn from(error: RuntimeError) -> Self { Error::Runtime(error) } } #[derive(Debug, PartialEq)] pub enum RuntimeError { RwLockPoison(RwLockPoisonError), ValidationFailure(ValidationError), } impl From for RuntimeError { fn from(error: RwLockPoisonError) -> Self { RuntimeError::RwLockPoison(error) } } impl From for RuntimeError { fn from(error: ValidationError) -> Self { RuntimeError::ValidationFailure(error) } } #[derive(Debug, PartialEq)] pub enum ValidationError { RwLockPoison(RwLockPoisonError), ExpectedBoolean, } impl From for ValidationError { fn from(error: RwLockPoisonError) -> Self { ValidationError::RwLockPoison(error) } } #[derive(Debug, PartialEq)] pub struct RwLockPoisonError; impl From> for RwLockPoisonError { fn from(_: PoisonError) -> Self { RwLockPoisonError } }