srdf/srdf_parser/
rdf_parser_error.rs

1use iri_s::IriS;
2use thiserror::Error;
3
4use crate::literal::Literal;
5
6#[derive(Debug, Error, PartialEq)]
7pub enum RDFParseError {
8    #[error("No focus node")]
9    NoFocusNode,
10
11    #[error("Expected focus node to be boolean but found: {term}")]
12    ExpectedBoolean { term: String },
13
14    #[error("Expected focus node to be integer but found: {term}")]
15    ExpectedInteger { term: String },
16
17    #[error("Expected focus node to be string but found: {term}")]
18    ExpectedString { term: String },
19
20    #[error("Expected IRI or Literal value but obtained blank node: {bnode}")]
21    BlankNodeNoValue { bnode: String },
22
23    #[error("RDF Error: {err}")]
24    SRDFError { err: String },
25
26    #[error("Node {node} has no value for predicate {pred}")]
27    NoValuesPredicate { node: String, pred: String },
28
29    #[error("Node {node} has no value for predicate {pred}. Outgoing arcs: {outgoing_arcs}")]
30    NoValuesPredicateDebug {
31        node: String,
32        pred: String,
33        outgoing_arcs: String,
34    },
35
36    #[error("Node {node} has more than one value for predicate {pred}: {value1}, {value2}")]
37    MoreThanOneValuePredicate {
38        node: String,
39        pred: String,
40        value1: String,
41        value2: String,
42    },
43
44    #[error("No instances found for {object}")]
45    NoInstancesOf { object: String },
46
47    #[error("More than one instance of {object}: instance1: {value1}, instance2: {value2}")]
48    MoreThanOneInstanceOf {
49        object: String,
50        value1: String,
51        value2: String,
52    },
53
54    #[error("Expected node to act as subject: {node}")]
55    ExpectedSubject { node: String },
56
57    #[error("Error parsing RDF list. Value: {node} has already been visited")]
58    RecursiveRDFList { node: String },
59
60    #[error("Expected IRI, but found {term}")]
61    ExpectedIRI { term: String },
62
63    #[error("Expected IRI but found BNode {bnode}")]
64    ExpectedIRIFoundBNode { bnode: String },
65
66    #[error("Expected Literal, but found {term}")]
67    ExpectedLiteral { term: String },
68
69    #[error("Expected focus to act as subject, found {focus}")]
70    ExpectedFocusAsSubject { focus: String },
71
72    #[error("Unexpected Blank Node: {term}")]
73    UnexpectedBNode { term: String },
74
75    #[error("Expected IRI but found Literal {lit}")]
76    ExpectedIRIFoundLiteral { lit: Literal },
77
78    #[error("Condition {condition_name} failed for node {node}")]
79    NodeDoesntSatisfyCondition {
80        condition_name: String,
81        node: String,
82    },
83
84    #[error("Both branches of an OR parser failed. Error1: {err1}, Error2: {err2}")]
85    FailedOr {
86        err1: Box<RDFParseError>,
87        err2: Box<RDFParseError>,
88    },
89
90    #[error("Not parser failed because internal parser passed with value: {value}")]
91    FailedNot { value: String },
92
93    #[error("Error obtaining subjects whose value for property {property} is {value}: {err}")]
94    ErrorSubjectsPredicateObject {
95        property: String,
96        value: String,
97        err: String,
98    },
99
100    #[error("Error parsing by type. Unknown type: {iri_type}")]
101    UnknownType { iri_type: IriS },
102
103    #[error("{msg}")]
104    Custom { msg: String },
105
106    #[error("Expected IRI for property {property} of node {focus}: {error}")]
107    PropertyValueExpectedIRI {
108        focus: String,
109        property: IriS,
110        error: String,
111    },
112}