diff options
Diffstat (limited to 'tvix/eval/src/errors.rs')
-rw-r--r-- | tvix/eval/src/errors.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 4aba877f4979..01a5e8144906 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -1,7 +1,7 @@ use std::fmt::Display; #[derive(Debug)] -pub enum Error { +pub enum ErrorKind { DuplicateAttrsKey { key: String, }, @@ -37,9 +37,21 @@ pub enum Error { AssertionFailed, } +#[derive(Debug)] +pub struct Error { + pub node: Option<rnix::SyntaxNode>, + pub kind: ErrorKind, +} + +impl From<ErrorKind> for Error { + fn from(kind: ErrorKind) -> Self { + Error { node: None, kind } + } +} + impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - writeln!(f, "{:?}", self) + writeln!(f, "{:?}", self.kind) } } |