about summary refs log tree commit diff
path: root/tvix/eval/src/lib.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2024-02-20T11·09+0700
committerclbot <clbot@tvl.fyi>2024-02-20T12·33+0000
commit20833656aee4aaefdd83e7beb141a5e03f8c956d (patch)
tree454af1a374146379cc4c4082d231e62c7bf7f52b /tvix/eval/src/lib.rs
parentd9565a4d0af3bffd735a77aa6f1fd0ec0e03b14a (diff)
fix(tvix/eval): propagate catchable errors at the top of an eval r/7577
(Re-)Adds an error variant that wraps a catchable error kind, which is
used for returning the result of an evaluation.

Previously this would return the internal catchable value, which would
lead to panics if users tried to use these. Somehow this was missed; I
think we need error output tests.

Change-Id: Id6e24aa2ce4ea4358a29b2e1cf4a6749986baf8c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10991
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval/src/lib.rs')
-rw-r--r--tvix/eval/src/lib.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/tvix/eval/src/lib.rs b/tvix/eval/src/lib.rs
index 8ce37de427..845964cb7e 100644
--- a/tvix/eval/src/lib.rs
+++ b/tvix/eval/src/lib.rs
@@ -301,7 +301,7 @@ where
             nix_path,
             self.io_handle,
             runtime_observer,
-            source,
+            source.clone(),
             globals,
             lambda,
             self.strict,
@@ -310,6 +310,15 @@ where
         match vm_result {
             Ok(mut runtime_result) => {
                 result.warnings.append(&mut runtime_result.warnings);
+                if let Value::Catchable(inner) = runtime_result.value {
+                    result.errors.push(Error::new(
+                        ErrorKind::CatchableError(*inner),
+                        file.span,
+                        source,
+                    ));
+                    return result;
+                }
+
                 result.value = Some(runtime_result.value);
             }
             Err(err) => {