use std::fmt;
#[derive(Debug, Clone)]
pub enum S2sError {
Lex { offset: usize, message: String },
Parse { line: usize, column: usize, message: String },
Unsupported(String),
}
impl fmt::Display for S2sError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Lex { offset, message } => {
write!(f, "Lexer error at offset {offset}: {message}")
}
Self::Parse { line, column, message } => {
write!(f, "Parse error at {line}:{column}: {message}")
}
Self::Unsupported(s) => write!(f, "Unsupported s2s construct: {s}"),
}
}
}
impl std::error::Error for S2sError {}
pub type S2sResult<T> = Result<T, S2sError>;