rudof_rdf/rdf_impl/in_memory_graph_error.rs
1use iri_s::error::IriSError;
2use oxiri::IriParseError;
3use oxttl::TurtleParseError;
4use prefixmap::PrefixMapError;
5use std::io;
6use std::io::Error as IOError;
7use thiserror::Error;
8
9/// Represents all possible errors that can occur when working with in-memory RDF graphs.
10#[derive(Error, Debug)]
11pub enum InMemoryGraphError {
12 /// Error processing query results.
13 ///
14 /// # Fields
15 /// - `msg`: Detailed description of the query result error
16 #[error("Query result error: {msg}")]
17 QueryResultError { msg: String },
18
19 /// Error extending query solutions with additional data.
20 ///
21 /// # Fields
22 /// - `query`: The query string being executed
23 /// - `error`: Detailed description of the extension failure
24 #[error("Error extending query solutions for query: {query}: {error}")]
25 ExtendingQuerySolutionsError { query: String, error: String },
26
27 /// Error parsing a query string.
28 ///
29 /// # Fields
30 /// - `msg`: Detailed description of the parsing failure
31 #[error("Parsing query error: {msg}")]
32 ParsingQueryError { msg: String },
33
34 /// Error executing a query.
35 ///
36 /// # Fields
37 /// - `query`: The query string that failed to execute
38 /// - `msg`: Detailed description of the execution failure
39 #[error("Running query {query} error: {msg}")]
40 RunningQueryError { query: String, msg: String },
41
42 /// Error parsing Turtle RDF data.
43 ///
44 /// # Fields
45 /// - `source_name`: The name or path of the data source
46 /// - `error`: Detailed description of the parsing failure
47 #[error("Error parsing Turtle data from {source_name}: {error}")]
48 TurtleParseError { source_name: String, error: String },
49
50 /// Error parsing a base IRI.
51 ///
52 /// # Fields
53 /// - `str`: The IRI string that failed to parse
54 /// - `error`: Detailed description of the parsing failure
55 #[error("Parsing base iri {str}: error: {error}")]
56 BaseParseError { str: String, error: String },
57
58 /// Error generating a blank node identifier.
59 ///
60 /// # Fields
61 /// - `msg`: Detailed description of the blank node generation failure
62 #[error("Blank node generation id: {msg}")]
63 BlankNodeId { msg: String },
64
65 /// Error reading data from a file path.
66 ///
67 /// # Fields
68 /// - `path_name`: The path that failed to be read
69 /// - `error`: The underlying I/O error
70 #[error("Reading path {path_name:?} error: {error:?}")]
71 ReadingPathError { path_name: String, error: io::Error },
72
73 /// Error reading Turtle data.
74 ///
75 /// # Fields
76 /// - `err`: The underlying Turtle parsing error
77 #[error(transparent)]
78 ErrorReadingTurtle {
79 #[from]
80 err: TurtleParseError,
81 },
82
83 /// General I/O error.
84 ///
85 /// # Fields
86 /// - `err`: The underlying I/O error
87 #[error(transparent)]
88 IOError {
89 #[from]
90 err: IOError,
91 },
92
93 /// Error parsing Turtle data with context.
94 ///
95 /// # Fields
96 /// - `data`: The Turtle data that failed to parse
97 /// - `turtle_error`: The underlying Turtle parsing error
98 #[error("Turtle error: {turtle_error}\nData:\n{data}")]
99 TurtleError {
100 data: String,
101 turtle_error: TurtleParseError,
102 },
103
104 /// Error parsing RDF/XML data.
105 ///
106 /// # Fields
107 /// - `data`: The RDF/XML data that failed to parse
108 /// - `error`: Detailed description of the parsing failure
109 #[error("RDF/XML error: {error}\nData: {data}")]
110 RDFXMLError { data: String, error: String },
111
112 /// Error parsing N-Triples data.
113 ///
114 /// # Fields
115 /// - `data`: The N-Triples data that failed to parse
116 /// - `error`: Detailed description of the parsing failure
117 #[error("N-Triples error: {error}\nData: {data}")]
118 NTriplesError { data: String, error: String },
119
120 /// Error parsing N-Quads data.
121 ///
122 /// # Fields
123 /// - `data`: The N-Quads data that failed to parse
124 /// - `error`: Detailed description of the parsing failure
125 #[error("NQuads error: {error}\nData: {data}")]
126 NQuadsError { data: String, error: String },
127
128 /// Error parsing JSON-LD data.
129 ///
130 /// # Fields
131 /// - `data`: The JSON-LD data that failed to parse
132 /// - `error`: Detailed description of the parsing failure
133 #[error("JSON-LD error: {error}\nData: {data}")]
134 JsonLDError { data: String, error: String },
135
136 /// Error parsing an IRI.
137 ///
138 /// # Fields
139 /// - `err`: The underlying IRI parsing error
140 #[error(transparent)]
141 IriParseError {
142 #[from]
143 err: IriParseError,
144 },
145
146 /// Error related to IRI string operations.
147 ///
148 /// # Fields
149 /// - `err`: The underlying IRI string error
150 #[error(transparent)]
151 IriSError {
152 #[from]
153 err: IriSError,
154 },
155
156 /// Error related to prefix map operations.
157 ///
158 /// # Fields
159 /// - `err`: The underlying prefix map error
160 #[error(transparent)]
161 PrefixMapError {
162 #[from]
163 err: PrefixMapError,
164 },
165}