inference_engine/reasoning/source/
error.rs1use super::super::{
2 DatatypeConflictError, LiteralTypingError, OccurrenceError, OccurrenceTypingError,
3 ReasoningError, TermOccurrence,
4};
5use std::{error::Error, fmt};
6
7#[derive(Debug)]
9pub enum Rdfs12SourceError<T, E> {
10 Reasoning(ReasoningError<E>),
12 Traversal(OccurrenceError<E>),
14 Occurrences(OccurrenceTypingError<E>),
16 Literals(LiteralTypingError<T, E>),
18 Vocabulary {
20 occurrence: TermOccurrence<T>,
22 error: E,
24 },
25 VocabularyLimit,
27 VocabularyIdentity,
29 PropositionIdentity,
31 Conflicts(DatatypeConflictError<E>),
33 DiagnosticLimit,
35 Rounds,
37 CounterOverflow,
39}
40impl<T, E> From<ReasoningError<E>> for Rdfs12SourceError<T, E> {
41 fn from(error: ReasoningError<E>) -> Self {
42 Self::Reasoning(error)
43 }
44}
45impl<T, E: fmt::Display> fmt::Display for Rdfs12SourceError<T, E> {
46 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47 match self {
48 Self::Reasoning(error) => error.fmt(f),
49 Self::Traversal(error) => error.fmt(f),
50 Self::Occurrences(error) => error.fmt(f),
51 Self::Literals(error) => error.fmt(f),
52 Self::Vocabulary { error, .. } => {
53 write!(f, "source container classification failed: {error}")
54 }
55 Self::VocabularyLimit => f.write_str("source container metadata limit exceeded"),
56 Self::VocabularyIdentity => {
57 f.write_str("source container descriptor does not match selected term")
58 }
59 Self::PropositionIdentity => {
60 f.write_str("source triple-term construction does not match selected term")
61 }
62 Self::Conflicts(error) => error.fmt(f),
63 Self::DiagnosticLimit => f.write_str("source literal diagnostic limit exceeded"),
64 Self::Rounds => f.write_str("source preparation round limit exceeded"),
65 Self::CounterOverflow => f.write_str("source preparation counter capacity exceeded"),
66 }
67 }
68}
69impl<T: fmt::Debug, E: Error + 'static> Error for Rdfs12SourceError<T, E> {
70 fn source(&self) -> Option<&(dyn Error + 'static)> {
71 match self {
72 Self::Reasoning(error) => Some(error),
73 Self::Traversal(error) => Some(error),
74 Self::Occurrences(error) => Some(error),
75 Self::Literals(error) => error.source(),
76 Self::Vocabulary { error, .. } => Some(error),
77 Self::Conflicts(error) => Some(error),
78 _ => None,
79 }
80 }
81}