spareval/
error.rs

1use oxrdf::{NamedNode, Term, Variable};
2use std::convert::Infallible;
3use std::error::Error;
4
5/// A SPARQL evaluation error
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum QueryEvaluationError {
9    /// Error from the underlying RDF dataset
10    #[error(transparent)]
11    Dataset(Box<dyn Error + Send + Sync>),
12    /// Error during `SERVICE` evaluation
13    #[error("{0}")]
14    Service(#[source] Box<dyn Error + Send + Sync>),
15    /// If a variable present in the given initial substitution is not present in the `SELECT` part of the query
16    #[error("The SPARQL query does not contains variable {0} in its SELECT projection")]
17    NotExistingSubstitutedVariable(Variable),
18    /// Error if the dataset returns the default graph even if a named graph is expected
19    #[error("The SPARQL dataset returned the default graph even if a named graph is expected")]
20    UnexpectedDefaultGraph,
21    /// The variable storing the `SERVICE` name is unbound
22    #[error("The variable encoding the service name is unbound")]
23    UnboundService,
24    /// Invalid service name
25    #[error("{0} is not a valid service name")]
26    InvalidServiceName(Term),
27    /// The given `SERVICE` is not supported
28    #[error("The service {0} is not supported")]
29    UnsupportedService(NamedNode),
30    #[cfg(feature = "rdf-star")]
31    #[error("The storage provided a triple term that is not a valid RDF-star term")]
32    InvalidStorageTripleTerm,
33}
34
35impl From<Infallible> for QueryEvaluationError {
36    #[inline]
37    fn from(error: Infallible) -> Self {
38        match error {}
39    }
40}