#[derive(Debug)]
#[non_exhaustive]
pub enum SymbolError {
Parse {
reason: String,
},
Unresolvable {
path: String,
reason: String,
},
BadPath {
reason: String,
},
Grammar(String),
}
impl std::fmt::Display for SymbolError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Parse { reason } => write!(f, "source does not parse cleanly: {reason}"),
Self::Unresolvable { path, reason } => {
write!(f, "symbol path `{path}` does not resolve: {reason}")
}
Self::BadPath { reason } => write!(f, "bad symbol path: {reason}"),
Self::Grammar(e) => write!(f, "grammar load failed: {e}"),
}
}
}
impl std::error::Error for SymbolError {}