srdf/srdf_parser/
rdf_parser_error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use iri_s::IriS;
use thiserror::Error;

use crate::literal::Literal;

#[derive(Debug, Error, PartialEq)]
pub enum RDFParseError {
    #[error("No focus node")]
    NoFocusNode,

    #[error("Expected focus node to be boolean but found: {term}")]
    ExpectedBoolean { term: String },

    #[error("Expected focus node to be integer but found: {term}")]
    ExpectedInteger { term: String },

    #[error("Expected focus node to be string but found: {term}")]
    ExpectedString { term: String },

    #[error("Expected IRI or Literal value but obtained blank node: {bnode}")]
    BlankNodeNoValue { bnode: String },

    #[error("RDF Error: {err}")]
    SRDFError { err: String },

    #[error("Node {node} has no value for predicate {pred}")]
    NoValuesPredicate { node: String, pred: String },

    #[error("Node {node} has no value for predicate {pred}. Outgoing arcs: {outgoing_arcs}")]
    NoValuesPredicateDebug {
        node: String,
        pred: String,
        outgoing_arcs: String,
    },

    #[error("Node {node} has more than one value for predicate {pred}: {value1}, {value2}")]
    MoreThanOneValuePredicate {
        node: String,
        pred: String,
        value1: String,
        value2: String,
    },

    #[error("No instances found for {object}")]
    NoInstancesOf { object: String },

    #[error("More than one instance of {object}: instance1: {value1}, instance2: {value2}")]
    MoreThanOneInstanceOf {
        object: String,
        value1: String,
        value2: String,
    },

    #[error("Expected node to act as subject: {node}")]
    ExpectedSubject { node: String },

    #[error("Error parsing RDF list. Value: {node} has already been visited")]
    RecursiveRDFList { node: String },

    #[error("Expected IRI, but found {term}")]
    ExpectedIRI { term: String },

    #[error("Expected IRI but found BNode {bnode}")]
    ExpectedIRIFoundBNode { bnode: String },

    #[error("Expected Literal, but found {term}")]
    ExpectedLiteral { term: String },

    #[error("Expected focus to act as subject, found {focus}")]
    ExpectedFocusAsSubject { focus: String },

    #[error("Unexpected Blank Node: {term}")]
    UnexpectedBNode { term: String },

    #[error("Expected IRI but found Literal {lit}")]
    ExpectedIRIFoundLiteral { lit: Literal },

    #[error("Condition {condition_name} failed for node {node}")]
    NodeDoesntSatisfyCondition {
        condition_name: String,
        node: String,
    },

    #[error("Both branches of an OR parser failed. Error1: {err1}, Error2: {err2}")]
    FailedOr {
        err1: Box<RDFParseError>,
        err2: Box<RDFParseError>,
    },

    #[error("Not parser failed because internal parser passed with value: {value}")]
    FailedNot { value: String },

    #[error("Error obtaining subjects whose value for property {property} is {value}: {err}")]
    ErrorSubjectsPredicateObject {
        property: String,
        value: String,
        err: String,
    },

    #[error("Error parsing by type. Unknown type: {iri_type}")]
    UnknownType { iri_type: IriS },

    #[error("{msg}")]
    Custom { msg: String },

    #[error("Expected IRI for property {property} of node {focus}: {error}")]
    PropertyValueExpectedIRI {
        focus: String,
        property: IriS,
        error: String,
    },
}