fastobo_owl/
error.rs

1use fastobo::error::CardinalityError;
2use fastobo::error::SyntaxError;
3
4/// The result type for this crate.
5pub type Result<T> = std::result::Result<T, Error>;
6
7/// The error type for this crate.
8#[derive(Debug, Error, PartialEq)]
9pub enum Error {
10    /// An error caused by a clause appearing an invalid number of times.
11    ///
12    /// For instance, OBO frames have `union_of` clauses, that can not appear
13    /// only once: they must appear zero, or more than two times. Having a
14    /// frame with a single `union_of` clause will error when attempting to
15    /// translate the whole document.
16    ///
17    /// # Example:
18    /// ```rust
19    /// # use std::str::FromStr;
20    /// # use fastobo::ast::*;
21    /// # use horned_owl::ontology::set::SetOntology;
22    /// use fastobo_owl::IntoOwl;
23    /// use fastobo_owl::IntoOwlPrefixes;
24    ///
25    /// let mut frame = TermFrame::new(ClassIdent::from(PrefixedIdent::new("TST", "001")));
26    /// let id = Box::new(ClassIdent::from(PrefixedIdent::new("TST", "002")));
27    /// frame.push(Line::from(TermClause::UnionOf(id)));
28    ///
29    /// let doc = OboDoc::with_entities(vec![EntityFrame::from(frame)]);
30    /// let res = doc.into_owl::<SetOntology<String>>();
31    /// assert!(matches!(res, Err(fastobo_owl::Error::Cardinality(_))));
32    /// ```
33    #[error(transparent)]
34    Cardinality(#[from] CardinalityError),
35
36    #[error(transparent)]
37    /// An error caused by an element in invalid syntax.
38    ///
39    /// This can be raised while building IRI and Version IRI for an OWL
40    /// ontology from an OBO `ontology` header clause, which may contain
41    /// invalid data.
42    ///
43    Syntax(#[from] SyntaxError),
44}