about summary refs log tree commit diff
path: root/tvix/eval/src/vm/generators.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/vm/generators.rs')
-rw-r--r--tvix/eval/src/vm/generators.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs
index b05ba3d7c4df..853ab063465f 100644
--- a/tvix/eval/src/vm/generators.rs
+++ b/tvix/eval/src/vm/generators.rs
@@ -400,19 +400,15 @@ impl<'o> VM<'o> {
                         }
 
                         VMRequest::PathImport(path) => {
-                            let imported = self
-                                .io_handle
-                                .import_path(&path)
-                                .map_err(|kind| Error::new(kind, span.span()))?;
+                            let imported =
+                                self.io_handle.import_path(&path).with_span(&span, self)?;
 
                             message = VMResponse::Path(imported);
                         }
 
                         VMRequest::ReadToString(path) => {
-                            let content = self
-                                .io_handle
-                                .read_to_string(path)
-                                .map_err(|kind| Error::new(kind, span.span()))?;
+                            let content =
+                                self.io_handle.read_to_string(path).with_span(&span, self)?;
 
                             message = VMResponse::Value(Value::String(content.into()))
                         }
@@ -422,17 +418,13 @@ impl<'o> VM<'o> {
                                 .io_handle
                                 .path_exists(path)
                                 .map(Value::Bool)
-                                .map_err(|kind| Error::new(kind, span.span()))?;
+                                .with_span(&span, self)?;
 
                             message = VMResponse::Value(exists);
                         }
 
                         VMRequest::ReadDir(path) => {
-                            let dir = self
-                                .io_handle
-                                .read_dir(path)
-                                .map_err(|kind| Error::new(kind, span.span()))?;
-
+                            let dir = self.io_handle.read_dir(path).with_span(&span, self)?;
                             message = VMResponse::Directory(dir);
                         }
 
@@ -466,7 +458,7 @@ impl<'o> VM<'o> {
                 // Generator has completed, and its result value should
                 // be left on the stack.
                 genawaiter::GeneratorState::Complete(result) => {
-                    let value = result.map_err(|kind| Error::new(kind, span.span()))?;
+                    let value = result.with_span(&span, self)?;
                     self.stack.push(value);
                     return Ok(true);
                 }