shapes_converter/shex_to_sparql/
shex2sparql_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
use prefixmap::IriRef;
use shex_ast::{Schema, SchemaJsonError, ShapeExprLabel};
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ShEx2SparqlError {
    #[error("Shape {iri} not found in schema {schema:?}")]
    ShapeNotFound { iri: IriRef, schema: Schema },

    #[error("Shape reference {sref} not found in schema {schema:?}")]
    ShapeRefNotFound {
        sref: ShapeExprLabel,
        schema: Schema,
    },

    #[error("No shapes found in schema to convert to SPARQL. Schema\n{schema:?}")]
    NoShapes { schema: Schema },

    #[error(
        "No shape found to convert to SPARQL because list of shapes is empty. Schema\n{schema:?}"
    )]
    EmptyShapes { schema: Schema },

    #[error(transparent)]
    SchemaError {
        #[from]
        err: SchemaJsonError,
    },

    #[error("ShEx2Sparql: Feature not implemented: {msg}")]
    NotImplemented { msg: String },
}

impl ShEx2SparqlError {
    pub fn not_implemented(msg: &str) -> ShEx2SparqlError {
        ShEx2SparqlError::NotImplemented {
            msg: msg.to_string(),
        }
    }
}