query_algebrizer_traits/
errors.rs1use std;
12
13use core_traits::{ValueType, ValueTypeSet};
14
15use edn::{query::PlainSymbol, ParseError};
16
17use thiserror::Error;
18
19pub type Result<T> = std::result::Result<T, AlgebrizerError>;
20
21#[derive(Clone, Debug, Eq, PartialEq)]
22pub enum BindingError {
23 NoBoundVariable,
24 UnexpectedBinding,
25 RepeatedBoundVariable, ExpectedBindRel,
30
31 ExpectedBindRelOrBindColl,
35
36 InvalidNumberOfBindings {
39 number: usize,
40 expected: usize,
41 },
42}
43
44#[derive(Clone, Debug, Eq, Error, PartialEq)]
45pub enum AlgebrizerError {
46 #[error("{0} var {1} is duplicated")]
47 DuplicateVariableError(PlainSymbol, &'static str),
48
49 #[error("unexpected FnArg")]
50 UnsupportedArgument,
51
52 #[error("value of type {0} provided for var {1}, expected {2}")]
53 InputTypeDisagreement(PlainSymbol, ValueType, ValueType),
54
55 #[error("invalid number of arguments to {0}: expected {1}, got {2}.")]
56 InvalidNumberOfArguments(PlainSymbol, usize, usize),
57
58 #[error("invalid argument to {0}: expected {1} in position {2}.")]
59 InvalidArgument(PlainSymbol, &'static str, usize),
60
61 #[error("invalid argument to {0}: expected one of {1:?} in position {2}.")]
62 InvalidArgumentType(PlainSymbol, ValueTypeSet, usize),
63
64 #[error("invalid expression in ground constant")]
66 InvalidGroundConstant,
67
68 #[error("invalid limit {0} of type {1}: expected natural number.")]
69 InvalidLimit(String, ValueType),
70
71 #[error("mismatched bindings in ground")]
72 GroundBindingsMismatch,
73
74 #[error("no entid found for ident: {0}")]
75 UnrecognizedIdent(String),
76
77 #[error("no function named {0}")]
78 UnknownFunction(PlainSymbol),
79
80 #[error(":limit var {0} not present in :in")]
81 UnknownLimitVar(PlainSymbol),
82
83 #[error("unbound variable {0} in order clause or function call")]
84 UnboundVariable(PlainSymbol),
85
86 #[error("non-matching variables in 'or' clause")]
88 NonMatchingVariablesInOrClause,
89
90 #[error("non-matching variables in 'not' clause")]
91 NonMatchingVariablesInNotClause,
92
93 #[error("binding error in {0}: {1:?}")]
94 InvalidBinding(PlainSymbol, BindingError),
95
96 #[error("no rule named {0}")]
97 UnknownRule(PlainSymbol),
98
99 #[error("rule {0} invoked with {1} args but its definition takes {2}")]
100 RuleArgumentMismatch(PlainSymbol, usize, usize),
101
102 #[error("recursive rule {0} is not yet supported in the embedded engine")]
103 RecursiveRuleUnsupported(PlainSymbol),
104
105 #[error("multi-clause rule {0} is not yet supported in the embedded engine")]
106 MultiClauseRuleUnsupported(PlainSymbol),
107
108 #[error("bigint constants are not yet supported in this position (#280)")]
109 UnsupportedBigInteger,
110
111 #[error(
112 "queries against a non-default source (`{0}`) are not yet supported by the SQLite engine"
113 )]
114 UnsupportedSource(String),
115
116 #[error("{0}")]
117 EdnParseError(ParseError), }
119
120impl core::convert::From<ParseError> for AlgebrizerError {
121 fn from(error: ParseError) -> AlgebrizerError {
122 AlgebrizerError::EdnParseError(error)
123 }
124}