1use std::io;
2
3use iri_s::IriS;
4use shacl_ast::Schema;
5use srdf::SRDFSparql;
6use thiserror::Error;
7
8#[derive(Error, Debug)]
9pub enum RudofError {
10 #[error("Error reading config file from path {path}: {error}")]
11 RudofConfigFromPathError { path: String, error: io::Error },
12
13 #[error("Error reading config file from path {path}: {error}")]
14 RudofConfigTomlError {
15 path: String,
16 error: toml::de::Error,
17 },
18
19 #[error("Error running query {str}: {error}")]
20 QueryError { str: String, error: String },
21
22 #[error("Storage error: {error}")]
23 StorageError { error: String },
24
25 #[error("Error parsing IRI from {str}: {error}")]
26 BaseIriError { str: String, error: String },
27
28 #[error("ShEx compact parser error: {error}")]
29 ShExCParserError { error: String },
30
31 #[error("ShEx JSON parser error: {error}")]
32 ShExJParserError { error: String },
33
34 #[error("Compiling schema error: {error}")]
35 CompilingSchemaError { error: String },
36
37 #[error("ShEx Validator undefined. Before trying to validate with ShEx, a ShEx validator must be initialized in rudof")]
38 ShExValidatorUndefined {},
39
40 #[error("Error creating schema for ShEx validation. Schema:\n{schema}\nError: {error} ")]
41 ShExValidatorCreationError { schema: String, error: String },
42
43 #[error(
44 "ShEx validation error. Query map: {query_map}\nSchema:\n{schema}\nData:\n{rdf_data}\nError: {error} "
45 )]
46 ShExValidatorError {
47 schema: String,
48 rdf_data: String,
49 query_map: String,
50 error: String,
51 },
52
53 #[error("ShEx validation error. Error: {error} ")]
54 ShExValidatorObtainingResultMapError {
55 schema: String,
56 rdf_data: String,
57 shapemap: String,
58 error: String,
59 },
60
61 #[error("Error merging current RDF data, format: {format}, base: {base}, reader_mode: {reader_mode}: {error} ")]
62 MergeRDFDataFromReader {
63 format: String,
64 base: String,
65 reader_mode: String,
66 error: String,
67 },
68
69 #[error("Utf8 error: {error} ")]
70 Utf8Error { error: String },
71
72 #[error("Shapemap parse error on str: {str}: {error}")]
73 ShapeMapParseError { str: String, error: String },
74
75 #[error("Read error: {error} ")]
76 ReadError { error: String },
77
78 #[error("AddingEndpoint: {iri} ")]
79 AddingEndpointError { iri: IriS, error: String },
80
81 #[error("Validating shex requires to initialize a shapemap or a node/shape pair")]
82 NoShapeMap { schema: String },
83
84 #[error("Rsolving imports in ShEx schema: {error}")]
85 ResolvingImportsShExSchema { error: String },
86
87 #[error("Attempt to resolve import declarations without defining ShEx schema")]
88 NoShExSchemaForResolvingImports,
89
90 #[error("Internal SHACL Format is not readable. Only for output")]
91 InternalSHACLFormatNonReadable,
92
93 #[error("SHACL Parser error: {error}")]
94 SHACLParseError { error: String },
95
96 #[error("SHACL Compilation from schema {schema} error: {error}")]
97 SHACLCompilationError { error: String, schema: Box<Schema> },
98
99 #[error("SHACL Validation from schema {schema} error: {error}")]
100 SHACLValidationError { error: String, schema: Box<Schema> },
101
102 #[error("Creating Endpoint validation for SHACL from endpoint {endpoint:?}. error: {error}")]
103 SHACLEndpointValidationCreation { error: String, endpoint: SRDFSparql },
104
105 #[error("Parsing RDF data error: {error}")]
106 ParsingRDFDataReader { error: String },
107
108 #[error("No graph and no first endpoint to validate SHACL")]
109 NoGraphNoFirstEndpoint,
110
111 #[error("No SHACL schema defined")]
112 NoShaclSchema,
113
114 #[error("Cannot serialize current ShEx schema because it has not been defined")]
115 NoShExSchemaToSerialize,
116
117 #[cfg(feature = "dctap")]
118 #[error("No DCTAP defined")]
119 NoDCTAP,
120
121 #[error("ShEx2UML: No ShEx schema")]
122 ShEx2UmlWithoutShEx,
123
124 #[error("ShEx2PlantUML Error: {error}")]
125 ShEx2PlantUmlError { error: String },
126
127 #[error("ShEx2PlantUML Error when generating PlantUML: {error}")]
128 ShEx2PlantUmlErrorAsPlantUML { error: String },
129
130 #[error("Reading ShEx Schema from path: {path}: {error}")]
131 ReadingShExPath { path: String, error: String },
132
133 #[error("Error formatting schema {schema}: {error}")]
134 ErrorFormattingSchema { schema: String, error: String },
135
136 #[error("Error formatting shapemap {shapemap}: {error}")]
137 ErrorFormattingShapeMap { shapemap: String, error: String },
138
139 #[error("Error formatting schema: {error}")]
140 ErrorWritingShExJson { schema: String, error: String },
141
142 #[error("Not implemented yet: {msg}")]
143 NotImplemented { msg: String },
144
145 #[error("Cannot serialize current ShapeMap because it has not been defined")]
146 NoShapeMapToSerialize,
147
148 #[error("Cannot serialize current SHACL because it has not been defined")]
149 NoShaclToSerialize,
150
151 #[error("Converting SHACLFormat with value Internal to RDFFormat")]
152 NoInternalFormatForRDF,
153
154 #[error("Serializing SHACL to internal representation: {error}")]
155 SerializingSHACLInternal { error: String },
156
157 #[error("Writing SHACL {shacl}: {error}")]
158 WritingSHACL { shacl: String, error: String },
159
160 #[error("Serializing SHACL {shacl}: {error}")]
161 SerializingSHACL { shacl: String, error: String },
162
163 #[error("Serializing ShEx: {error}")]
164 SerializingShEx { error: String },
165
166 #[error("Serializing RDF data: {error}")]
167 SerializingData { error: String },
168
169 #[error("Serializing ShEx: {error}")]
170 SerializingShacl { error: String },
171
172 #[cfg(feature = "dctap")]
173 #[error("DCTAP reader from path {path} in CSV format: {error}")]
174 DCTAPReaderCSV { error: String, path: String },
175
176 #[cfg(feature = "dctap")]
177 #[error("DCTAP reader from path {path}: {error}")]
178 ReadingDCTAPPath { error: String, path: String },
179
180 #[cfg(feature = "dctap")]
181 #[error("DCTAP reader in CSV format: {error}")]
182 DCTAPReaderCSVReader { error: String },
183
184 #[cfg(feature = "dctap")]
185 #[error("DCTAP reader from path {path} in CSV format: {error}")]
186 DCTAPReaderPathXLS {
187 error: String,
188 path: String,
189 format: String,
190 },
191
192 #[cfg(feature = "dctap")]
193 #[error("Reading DCTAP from XLS format requires a Path, use read_dctap_path")]
194 DCTAPReadXLSNoPath,
195
196 #[cfg(feature = "dctap")]
197 #[error("Error converting DCTAP to ShEx")]
198 DCTap2ShEx { error: String },
199}