about summary refs log tree commit diff
path: root/tvix/eval/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/errors.rs')
-rw-r--r--tvix/eval/src/errors.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 72c98120729e..2963e7877dc6 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -601,6 +601,27 @@ to a missing value in the attribute set(s) included via `with`."#,
                 spans_for_parse_errors(&file, errors)
             }
 
+            // Unwrap thunk errors to the innermost one
+            // TODO: limit the number of intermediates!
+            ErrorKind::ThunkForce(err) => {
+                let mut labels = err.spans(source);
+
+                // Only add this thunk to the "cause chain" if it span isn't
+                // exactly identical to the next-higher level, which is very
+                // common for the last thunk in a chain.
+                if let Some(label) = labels.last() {
+                    if label.span != self.span {
+                        labels.push(SpanLabel {
+                            label: Some("while evaluating this".into()),
+                            span: self.span,
+                            style: SpanStyle::Secondary,
+                        });
+                    }
+                }
+
+                labels
+            }
+
             // All other errors pretty much have the same shape.
             _ => {
                 vec![SpanLabel {