shex_ast/ir/
schema_ir_error.rs1use iri_s::IriSError;
2use prefixmap::{IriRef, PrefixMapError};
3use srdf::lang::Lang;
4use thiserror::Error;
5
6use super::shape_label::ShapeLabel;
7use crate::ast::TripleExprLabel;
8use crate::{ast, Node};
9use srdf::numeric_literal::NumericLiteral;
10
11#[derive(Error, Debug, Clone)]
12pub enum SchemaIRError {
13 #[error("Parsing {str:?} as IRI")]
14 Str2IriError { str: String },
15
16 #[error("Parsing {str} as IRI: {err:?}")]
17 IriParseError { str: String, err: IriSError },
18
19 #[error("SchemaJson Error")]
20 SchemaJsonError(#[from] ast::SchemaJsonError),
21
22 #[error("Duplicated triple expression label in schema: {label:?}")]
23 DuplicatedTripleExprLabel { label: TripleExprLabel },
24
25 #[error("Converting min value {min} must be positive")]
26 MinLessZero { min: i32 },
27
28 #[error("Converting max value {max} must be > -1")]
29 MaxIncorrect { max: i32 },
30
31 #[error("NodeKind IRI but found {node}")]
32 NodeKindIri { node: Node },
33
34 #[error("NodeKind BNode but found {node}")]
35 NodeKindBNode { node: Node },
36
37 #[error("NodeKind Literal but found {node}")]
38 NodeKindLiteral { node: Node },
39
40 #[error("NodeKind NonLiteral but found {node}")]
41 NodeKindNonLiteral { node: Node },
42
43 #[error("Datatype expected {expected} but found {found} for literal with lexical form {lexical_form}")]
44 DatatypeDontMatch {
45 found: IriRef,
46 expected: IriRef,
47 lexical_form: String,
48 },
49
50 #[error("Datatype expected {expected} but found no literal {node}")]
51 DatatypeNoLiteral {
52 expected: Box<IriRef>,
53 node: Box<Node>,
54 },
55
56 #[error("Datatype expected {expected} but found String literal {lexical_form}")]
57 DatatypeDontMatchString {
58 expected: IriRef,
59 lexical_form: String,
60 },
61
62 #[error("Expected language tag {lang} for StringLiteral with lexical form {lexical_form}")]
63 DatatypeDontMatchLangString {
64 lexical_form: String,
65 lang: Box<Lang>,
66 },
67
68 #[error("Length of {node} = {found} doesn't match {expected}")]
69 LengthError {
70 expected: usize,
71 found: usize,
72 node: String,
73 },
74
75 #[error("MinLength of {node} = {found} doesn't match {expected}")]
76 MinLengthError {
77 expected: usize,
78 found: usize,
79 node: String,
80 },
81
82 #[error("MaxLength of {node} = {found} doesn't match {expected}")]
83 MaxLengthError {
84 expected: usize,
85 found: usize,
86 node: String,
87 },
88
89 #[error("NumericValue of {node} = {found} doesn't match minInclusive of {expected}")]
90 MinInclusiveError {
91 expected: NumericLiteral,
92 found: NumericLiteral,
93 node: String,
94 },
95
96 #[error("Node {node} is not a numeric literal")]
97 NonNumeric { node: String },
98
99 #[error("Shape label not found {shape_label}")]
100 ShapeLabelNotFound { shape_label: ShapeLabel },
101
102 #[error("Not implemented yet: {msg}")]
103 Todo { msg: String },
104
105 #[error("Can't convert prefixed name {prefix}:{local} to shape label")]
106 IriRef2ShapeLabelError { prefix: String, local: String },
107
108 #[error("Can't find prefixed name {prefix}:{local} in prefixmap: {err}")]
109 PrefixedNotFound {
110 prefix: String,
111 local: String,
112 err: Box<PrefixMapError>,
113 },
114
115 #[error("Label not found: {shape_label}")]
116 LabelNotFound { shape_label: ShapeLabel },
117
118 #[error("Internal: {msg}")]
119 Internal { msg: String },
120}