From b7ab6c08561143df9ab6eb2255a74c37719f48f2 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 21 May 2023 11:00:49 +0300 Subject: refactor(tvix/eval/io): use io::Error instead of tvix_eval errors We didn't return anything useful other than ErrorKind::IO anyways. We can use io::ErrorKind::Unsupported for DummyIO. Fixes b/271. Change-Id: Icb231e9b38168e8b6fa473bfa405d160357b317f Reviewed-on: https://cl.tvl.fyi/c/depot/+/8602 Autosubmit: flokli Tested-by: BuildkiteCI Reviewed-by: tazjin --- tvix/eval/src/vm/generators.rs | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'tvix/eval/src/vm') diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs index b7d8f7aeb5c5..0e3123ae3758 100644 --- a/tvix/eval/src/vm/generators.rs +++ b/tvix/eval/src/vm/generators.rs @@ -406,15 +406,27 @@ impl<'o> VM<'o> { } VMRequest::PathImport(path) => { - let imported = - self.io_handle.import_path(&path).with_span(&span, self)?; + let imported = self + .io_handle + .import_path(&path) + .map_err(|e| ErrorKind::IO { + path: Some(path), + error: e.into(), + }) + .with_span(&span, self)?; message = VMResponse::Path(imported); } VMRequest::ReadToString(path) => { - let content = - self.io_handle.read_to_string(path).with_span(&span, self)?; + let content = self + .io_handle + .read_to_string(path.clone()) + .map_err(|e| ErrorKind::IO { + path: Some(path), + error: e.into(), + }) + .with_span(&span, self)?; message = VMResponse::Value(Value::String(content.into())) } @@ -422,7 +434,11 @@ impl<'o> VM<'o> { VMRequest::PathExists(path) => { let exists = self .io_handle - .path_exists(path) + .path_exists(path.clone()) + .map_err(|e| ErrorKind::IO { + path: Some(path), + error: e.into(), + }) .map(Value::Bool) .with_span(&span, self)?; @@ -430,7 +446,14 @@ impl<'o> VM<'o> { } VMRequest::ReadDir(path) => { - let dir = self.io_handle.read_dir(path).with_span(&span, self)?; + let dir = self + .io_handle + .read_dir(path.clone()) + .map_err(|e| ErrorKind::IO { + path: Some(path), + error: e.into(), + }) + .with_span(&span, self)?; message = VMResponse::Directory(dir); } -- cgit 1.4.1