pub enum ValidationError {
ParseError {
file: PathBuf,
message: String,
line: usize,
column: usize,
},
ShapeLoadError {
file: PathBuf,
reason: String,
},
SparqlError {
message: String,
query: String,
},
IoError(Error),
OxigraphError(String),
InvalidConstraint {
message: String,
shape_iri: String,
},
TimeoutError {
duration_ms: u64,
limit_ms: u64,
},
SyntaxValidationFailed {
file: String,
line: usize,
column: usize,
language: String,
error: String,
},
General {
message: String,
},
}Expand description
Validation error types
Represents all possible errors that can occur during SHACL validation. Each variant provides context-specific information for debugging.
§Constitution Compliance
- ✓ Principle VII: Result<T,E> error handling (no panic in production)
- ✓ Uses thiserror for automatic Error trait implementation
- ✓ Context-rich error messages with file paths and line numbers where applicable
Variants§
ParseError
TTL syntax parsing error
Occurs when loading TTL files (ontology or shapes) with invalid Turtle syntax.
Example:
ParseError: Invalid Turtle syntax at line 42 in spec.ttl
Caused by: Unexpected token '<' expecting IRI or blank nodeFields
ShapeLoadError
SHACL shapes file loading error
Occurs when shapes.ttl file cannot be found, read, or contains invalid SHACL definitions.
Example:
ShapeLoadError: Could not load SHACL shapes from shapes.ttl
Caused by: File not foundFields
SparqlError
SPARQL query execution error
Occurs when a SPARQL query (generated from SHACL shapes) fails to execute against the RDF graph.
Example:
SparqlError: SPARQL query failed
Query: SELECT ?s WHERE { ?s a sk:UserStory }
Caused by: Unknown prefix 'sk'Fields
IoError(Error)
I/O error (file system operations)
Wraps std::io::Error for file operations (reading TTL files, writing reports).
Example:
IoError: Failed to read file: Permission denied (os error 13)OxigraphError(String)
Oxigraph-specific errors
Wraps Oxigraph errors (graph operations, SPARQL parsing, etc.)
Example:
OxigraphError: Failed to insert triple into graphInvalidConstraint
Invalid SHACL constraint configuration
Occurs when SHACL shapes contain unsupported or malformed constraints.
Example:
InvalidConstraint: Unsupported constraint type 'sh:uniqueLang' in shape :UserStoryShape
Supported: sh:minCount, sh:maxCount, sh:datatype, sh:in, sh:pattern, sh:minLength, sh:maxLengthFields
TimeoutError
Validation timeout
Occurs when validation exceeds configured timeout threshold.
Example:
TimeoutError: Validation exceeded 30s timeoutFields
SyntaxValidationFailed
Syntax validation failed for generated file
Occurs when a generated file contains syntax errors (e.g., invalid Rust code, malformed TOML, invalid JSON). Includes location information for debugging.
Example:
SyntaxValidationFailed in src/main.rs:42:10 [Rust]: expected `{` found `;`Fields
General
General validation error (fallback)
Occurs when validation fails but doesn’t fit specific categories. Used for conversion from other error types.
Example:
General: Input validation error: Invalid email formatImplementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn parse_error(
file: impl Into<PathBuf>,
message: impl Into<String>,
line: usize,
column: usize,
) -> Self
pub fn parse_error( file: impl Into<PathBuf>, message: impl Into<String>, line: usize, column: usize, ) -> Self
Create a parse error from file path and message
Sourcepub fn shape_load_error(
file: impl Into<PathBuf>,
reason: impl Into<String>,
) -> Self
pub fn shape_load_error( file: impl Into<PathBuf>, reason: impl Into<String>, ) -> Self
Create a shape load error
Sourcepub fn sparql_error(
message: impl Into<String>,
query: impl Into<String>,
) -> Self
pub fn sparql_error( message: impl Into<String>, query: impl Into<String>, ) -> Self
Create a SPARQL error
Sourcepub fn invalid_constraint(
message: impl Into<String>,
shape_iri: impl Into<String>,
) -> Self
pub fn invalid_constraint( message: impl Into<String>, shape_iri: impl Into<String>, ) -> Self
Create an invalid constraint error
Sourcepub fn timeout_error(duration_ms: u64, limit_ms: u64) -> Self
pub fn timeout_error(duration_ms: u64, limit_ms: u64) -> Self
Create a timeout error
Sourcepub fn timeout(context: impl Into<String>, limit_ms: u64) -> Self
pub fn timeout(context: impl Into<String>, limit_ms: u64) -> Self
Create a timeout error with context (for validation rules)
Sourcepub fn invalid_query(rule_id: &str, reason: &str) -> Self
pub fn invalid_query(rule_id: &str, reason: &str) -> Self
Create an invalid query error (for SPARQL validation rules)
Sourcepub fn query_execution(rule_id: &str, error: &str) -> Self
pub fn query_execution(rule_id: &str, error: &str) -> Self
Create a query execution error (for SPARQL validation rules)
Trait Implementations§
Source§impl Debug for ValidationError
impl Debug for ValidationError
Source§impl Display for ValidationError
impl Display for ValidationError
Source§impl Error for ValidationError
impl Error for ValidationError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for ValidationError
impl From<Error> for ValidationError
Source§impl From<InputValidationError> for ValidationError
impl From<InputValidationError> for ValidationError
Source§fn from(error: InputValidationError) -> Self
fn from(error: InputValidationError) -> Self
Source§impl From<LoaderError> for ValidationError
impl From<LoaderError> for ValidationError
Source§fn from(err: LoaderError) -> Self
fn from(err: LoaderError) -> Self
Source§impl From<QueryEvaluationError> for ValidationError
impl From<QueryEvaluationError> for ValidationError
Source§fn from(err: QueryEvaluationError) -> Self
fn from(err: QueryEvaluationError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for ValidationError
impl !UnwindSafe for ValidationError
impl Freeze for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin for ValidationError
impl UnsafeUnpin for ValidationError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> EvidenceKind for T
impl<T> EvidenceKind for T
default fn kind_label(&self) -> &'static str
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more