#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PugErrorCode {
InvalidIndentation,
InconsistentIndentation,
NoEndBracket,
BracketMismatch,
InvalidClassName,
InvalidId,
InvalidAttribute,
UnexpectedText,
MalformedKeyword,
InvalidToken,
BlockOutsideMixin,
SourceTooLarge,
}
impl PugErrorCode {
pub fn message(self) -> &'static str {
match self {
Self::InvalidIndentation => {
"Invalid indentation, you can use tabs or spaces but not both"
}
Self::InconsistentIndentation => "Inconsistent indentation",
Self::NoEndBracket => "The end of the string reached with no closing bracket",
Self::BracketMismatch => "Mismatched bracket",
Self::InvalidClassName => "Class names must contain at least one letter or underscore",
Self::InvalidId => "Invalid ID",
Self::InvalidAttribute => "Invalid attribute",
Self::UnexpectedText => "Unexpected text",
Self::MalformedKeyword => "Malformed pug keyword",
Self::InvalidToken => "Unexpected token",
Self::BlockOutsideMixin => {
"Anonymous blocks are not allowed unless they are part of a mixin."
}
Self::SourceTooLarge => "Pug source is too large to address with u32 offsets",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PugError {
pub code: PugErrorCode,
pub offset: u32,
}