use core::{fmt, str};
pub enum ErrorKind {
StaticAbsent, DynamicAbsent, StaticSyntax, TypeError, StaticData, StaticUndefined, StaticNamespace, StaticBadFunction, MixedTypes, NotNodes, ContextNotNode, NotImplemented,
Unknown,
}
impl ErrorKind {
pub fn to_string(&self) -> &'static str {
match *self {
ErrorKind::StaticAbsent => "a component of the static context is absent",
ErrorKind::DynamicAbsent => "a component of the dynamic context is absent",
ErrorKind::StaticSyntax => "syntax error",
ErrorKind::TypeError => "type error",
ErrorKind::StaticData => "wrong static type",
ErrorKind::StaticUndefined => "undefined name",
ErrorKind::StaticNamespace => "namespace axis not supported",
ErrorKind::StaticBadFunction => "function call name and arity do not match",
ErrorKind::MixedTypes => "result of path operator contains both nodes and non-nodes",
ErrorKind::NotNodes => "path expression is not a sequence of nodes",
ErrorKind::ContextNotNode => "context item is not a node for an axis step",
ErrorKind::NotImplemented => "not implemented",
ErrorKind::Unknown => "unknown",
}
}
}
pub struct Error {
pub kind: ErrorKind,
pub message: String,
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&self.message)
}
}