use plotnik_core::Symbol;
#[derive(Clone, Debug)]
pub enum EmitError {
InvalidQuery,
TooManyStrings(usize),
TooManyTypes(usize),
TooManyTypeMembers(usize),
TooManyEntrypoints(usize),
TooManyTransitions(usize),
TooManyRegexes(usize),
StringNotFound(Symbol),
RegexCompile(String, String),
Compile(crate::compile::CompileError),
}
impl std::fmt::Display for EmitError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::InvalidQuery => write!(f, "query has validation errors"),
Self::TooManyStrings(n) => write!(f, "too many strings: {n} (max 65534)"),
Self::TooManyTypes(n) => write!(f, "too many types: {n} (max 65533)"),
Self::TooManyTypeMembers(n) => write!(f, "too many type members: {n} (max 65535)"),
Self::TooManyEntrypoints(n) => write!(f, "too many entrypoints: {n} (max 65535)"),
Self::TooManyTransitions(n) => write!(f, "too many transitions: {n} (max 65535)"),
Self::TooManyRegexes(n) => write!(f, "too many regexes: {n} (max 65535)"),
Self::StringNotFound(sym) => write!(f, "string not found for symbol: {sym:?}"),
Self::RegexCompile(pat, err) => write!(f, "regex compile error for '{pat}': {err}"),
Self::Compile(e) => write!(f, "compilation error: {e}"),
}
}
}
impl std::error::Error for EmitError {}