#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum GraphmlError {
#[error("GraphML: XML error at byte {position}: {detail}")]
Xml {
position: u64,
detail: String,
},
#[error("GraphML: unexpected end of document at byte {position}")]
UnexpectedEof {
position: u64,
},
#[error("GraphML: <{element}> at byte {position} lacks the '{attribute}' attribute")]
MissingAttribute {
element: &'static str,
attribute: &'static str,
position: u64,
},
#[error("GraphML: <data key=\"{key}\"> at byte {position} references an undeclared <key>")]
UndeclaredKey {
key: String,
position: u64,
},
#[error("GraphML: <data> at byte {position} is not inside a <node> or <edge>")]
DataOutsideElement {
position: u64,
},
#[error("GraphML: edge {source_id} -> {target_id} has no label")]
EdgeWithoutLabel {
source_id: String,
target_id: String,
},
}
impl GraphmlError {
pub(crate) fn xml(position: u64, error: &quick_xml::Error) -> Self {
Self::Xml {
position,
detail: error.to_string(),
}
}
}