use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LimaDiagnosticCode {
InvalidEscape,
InvalidQuote,
InvalidDate,
InvalidNumber,
InvalidReferenceShape,
InvalidIndentation,
InvalidFlowSyntax,
DuplicateKey,
ResourceLimit,
UnresolvedReference,
InvalidInterpolation,
InvalidPartial,
}
#[derive(Debug, Clone)]
pub struct LimaError {
pub code: LimaDiagnosticCode,
pub message: String,
pub line: Option<u32>,
pub key: Option<String>,
}
impl LimaError {
pub fn new(code: LimaDiagnosticCode, line: u32, message: impl Into<String>) -> Self {
Self {
code,
message: message.into(),
line: Some(line),
key: None,
}
}
}
impl fmt::Display for LimaError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl std::error::Error for LimaError {}