2022-08-04 15:43:51 +02:00
|
|
|
use std::fmt::Display;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2022-08-08 01:16:02 +02:00
|
|
|
pub enum Error {
|
2022-08-09 17:56:21 +02:00
|
|
|
DuplicateAttrsKey {
|
|
|
|
key: String,
|
|
|
|
},
|
|
|
|
|
2022-08-11 14:29:11 +02:00
|
|
|
AttributeNotFound {
|
|
|
|
name: String,
|
|
|
|
},
|
|
|
|
|
2022-08-08 01:16:02 +02:00
|
|
|
TypeError {
|
|
|
|
expected: &'static str,
|
|
|
|
actual: &'static str,
|
|
|
|
},
|
2022-08-11 10:37:04 +02:00
|
|
|
|
|
|
|
Incomparable {
|
|
|
|
lhs: &'static str,
|
|
|
|
rhs: &'static str,
|
|
|
|
},
|
2022-08-12 17:12:28 +02:00
|
|
|
|
|
|
|
// Resolving a user-supplied path literal failed in some way.
|
|
|
|
PathResolution(String),
|
2022-08-13 18:42:50 +02:00
|
|
|
|
|
|
|
// Dynamic keys are not allowed in let.
|
|
|
|
DynamicKeyInLet(rnix::SyntaxNode),
|
2022-08-13 19:17:25 +02:00
|
|
|
|
|
|
|
// Unknown variable in statically known scope.
|
2022-08-16 22:43:45 +02:00
|
|
|
UnknownStaticVariable(rnix::ast::Ident),
|
2022-08-15 00:13:17 +02:00
|
|
|
|
|
|
|
// Unknown variable in dynamic scope (with, rec, ...).
|
|
|
|
UnknownDynamicVariable(String),
|
2022-08-15 00:47:30 +02:00
|
|
|
|
|
|
|
ParseErrors(Vec<rnix::parser::ParseError>),
|
2022-08-16 14:53:35 +02:00
|
|
|
|
|
|
|
AssertionFailed,
|
2022-08-08 01:16:02 +02:00
|
|
|
}
|
2022-08-04 15:43:51 +02:00
|
|
|
|
|
|
|
impl Display for Error {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
2022-08-09 16:46:51 +02:00
|
|
|
writeln!(f, "{:?}", self)
|
2022-08-04 15:43:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type EvalResult<T> = Result<T, Error>;
|