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