plotnik_compiler/emit/
error.rs1use plotnik_core::Symbol;
4
5#[derive(Clone, Debug)]
7pub enum EmitError {
8 InvalidQuery,
10 TooManyStrings(usize),
12 TooManyTypes(usize),
14 TooManyTypeMembers(usize),
16 TooManyEntrypoints(usize),
18 TooManyTransitions(usize),
20 TooManyRegexes(usize),
22 StringNotFound(Symbol),
24 RegexCompile(String, String),
26 Compile(crate::compile::CompileError),
28}
29
30impl std::fmt::Display for EmitError {
31 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32 match self {
33 Self::InvalidQuery => write!(f, "query has validation errors"),
34 Self::TooManyStrings(n) => write!(f, "too many strings: {n} (max 65534)"),
35 Self::TooManyTypes(n) => write!(f, "too many types: {n} (max 65533)"),
36 Self::TooManyTypeMembers(n) => write!(f, "too many type members: {n} (max 65535)"),
37 Self::TooManyEntrypoints(n) => write!(f, "too many entrypoints: {n} (max 65535)"),
38 Self::TooManyTransitions(n) => write!(f, "too many transitions: {n} (max 65535)"),
39 Self::TooManyRegexes(n) => write!(f, "too many regexes: {n} (max 65535)"),
40 Self::StringNotFound(sym) => write!(f, "string not found for symbol: {sym:?}"),
41 Self::RegexCompile(pat, err) => write!(f, "regex compile error for '{pat}': {err}"),
42 Self::Compile(e) => write!(f, "compilation error: {e}"),
43 }
44 }
45}
46
47impl std::error::Error for EmitError {}