diff options
Diffstat (limited to 'tvix/eval/src')
-rw-r--r-- | tvix/eval/src/errors.rs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 5437db7bcbb6..8f782cb86151 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use std::rc::Rc; use std::str::Utf8Error; use std::sync::Arc; -use std::{fmt::Display, num::ParseIntError}; +use std::{fmt::Debug, fmt::Display, num::ParseIntError}; use codemap::{File, Span}; use codemap_diagnostic::{ColorConfig, Diagnostic, Emitter, Level, SpanLabel, SpanStyle}; @@ -141,6 +141,13 @@ pub enum ErrorKind { formals_span: Span, }, + /// Variant for code paths that are known bugs in Tvix (usually + /// issues with the compiler/VM interaction). + TvixBug { + msg: &'static str, + metadata: Option<Rc<dyn Debug>>, + }, + /// Tvix internal warning for features triggered by users that are /// not actually implemented yet, and without which eval can not /// proceed. @@ -376,6 +383,16 @@ to a missing value in the attribute set(s) included via `with`."#, ) } + ErrorKind::TvixBug { msg, metadata } => { + write!(f, "Tvix bug: {}", msg)?; + + if let Some(metadata) = metadata { + write!(f, "; metadata: {:?}", metadata)?; + } + + Ok(()) + } + ErrorKind::NotImplemented(feature) => { write!(f, "feature not yet implemented in Tvix: {}", feature) } @@ -658,6 +675,7 @@ impl Error { | ErrorKind::ImportCompilerError { .. } | ErrorKind::IO { .. } | ErrorKind::FromJsonError(_) + | ErrorKind::TvixBug { .. } | ErrorKind::NotImplemented(_) => return None, }; @@ -700,6 +718,10 @@ impl Error { ErrorKind::UnexpectedArgument { .. } => "E031", ErrorKind::RelativePathResolution(_) => "E032", + // Special error code that is not part of the normal + // ordering. + ErrorKind::TvixBug { .. } => "E998", + // Placeholder error while Tvix is under construction. ErrorKind::NotImplemented(_) => "E999", |