use std::fmt::Display;
use crate::{ast1::ScopeVariant, InternalError};
#[derive(Debug)]
#[cfg_attr(feature = "eq", derive(PartialEq, Eq))]
pub struct Error {
pub line: u32,
pub r#type: ErrorType,
}
impl Error {
pub fn new(line: u32, r#type: ErrorType) -> Self {
Self { line, r#type }
}
}
#[derive(Debug)]
#[cfg_attr(feature = "eq", derive(PartialEq, Eq))]
pub enum ErrorType {
UnexpectedClosing(ScopeVariant),
UnclosedArgument(ScopeVariant),
UnclosedScope(ScopeVariant),
NoEnvironmentLabel,
UnexpectedEnd(String),
UnclosedEnvironment(String),
TooManyArgsEnd,
TooManyArgsDocumentClass,
DoubleDocumentClass,
UnexpectedMathsEnd,
UnclosedMaths,
Internal(InternalError),
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!("{self:?}"))
}
}
impl std::error::Error for Error {}