about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-06T14·35+0300
committerclbot <clbot@tvl.fyi>2022-10-08T17·27+0000
commit167718614429322655fa352d20c754612da8d1a8 (patch)
tree74ebb81df1fc6c605186f1409e48ccbc50d0c2fb /tvix
parent9b1a266197d4edb55d40415464f7106c72ad6149 (diff)
feat(tvix/eval): add some slightly more descriptive span labels r/5065
Change-Id: I530c491f60a33fdb97e1553b193de51e7ee57d9a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6873
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/errors.rs37
1 files changed, 36 insertions, 1 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 2963e7877dc6..51fece840fae 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -392,7 +392,42 @@ impl Error {
     /// Create the optional span label displayed as an annotation on
     /// the underlined span of the error.
     fn span_label(&self) -> Option<String> {
-        None
+        let label = match &self.kind {
+            ErrorKind::DuplicateAttrsKey { .. } => "in this attribute set",
+            ErrorKind::InvalidAttributeName(_) => "in this attribute set",
+            ErrorKind::PathResolution(_) => "in this path literal",
+
+            // The spans for some errors don't have any more descriptive stuff
+            // in them, or we don't utilise it yet.
+            ErrorKind::Throw(_)
+            | ErrorKind::Abort(_)
+            | ErrorKind::AssertionFailed
+            | ErrorKind::AttributeNotFound { .. }
+            | ErrorKind::IndexOutOfBounds { .. }
+            | ErrorKind::TailEmptyList
+            | ErrorKind::TypeError { .. }
+            | ErrorKind::Incomparable { .. }
+            | ErrorKind::DynamicKeyInScope(_)
+            | ErrorKind::UnknownStaticVariable
+            | ErrorKind::UnknownDynamicVariable(_)
+            | ErrorKind::VariableAlreadyDefined(_)
+            | ErrorKind::NotCallable(_)
+            | ErrorKind::InfiniteRecursion
+            | ErrorKind::ParseErrors(_)
+            | ErrorKind::ThunkForce(_)
+            | ErrorKind::NotCoercibleToString { .. }
+            | ErrorKind::NotAnAbsolutePath(_)
+            | ErrorKind::ParseIntError(_)
+            | ErrorKind::NegativeLength { .. }
+            | ErrorKind::UnmergeableInherit { .. }
+            | ErrorKind::UnmergeableValue
+            | ErrorKind::ReadFileError { .. }
+            | ErrorKind::ImportParseError { .. }
+            | ErrorKind::ImportCompilerError { .. }
+            | ErrorKind::NotImplemented(_) => return None,
+        };
+
+        Some(label.into())
     }
 
     /// Create the primary error message displayed to users.