use std::fmt;
use crate::triple::Triple;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ParseError {
EmptyInput,
InvalidTriple(Box<Triple>),
AmbiguousType {
predicate: String,
candidates: Vec<String>,
},
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ParseError::EmptyInput => {
write!(f, "the supplied text could not be parsed into a triple")
}
ParseError::InvalidTriple(triple) => write!(f, "invalid triple: {triple:?}"),
ParseError::AmbiguousType {
predicate,
candidates,
} => write!(
f,
"ambiguous type for predicate {predicate:?}: candidates {candidates:?}"
),
}
}
}
impl std::error::Error for ParseError {}