diff options
author | Florian Klink <flokli@flokli.de> | 2023-05-21T08·00+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-05-22T09·42+0000 |
commit | b7ab6c08561143df9ab6eb2255a74c37719f48f2 (patch) | |
tree | e851244865739112b3e287896d000d5cb6cbdb55 /tvix/eval/src/vm/generators.rs | |
parent | 03958a5446a1d03caed9bd2f90a8327331cd4e91 (diff) |
refactor(tvix/eval/io): use io::Error instead of tvix_eval errors r/6171
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 <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/vm/generators.rs')
-rw-r--r-- | tvix/eval/src/vm/generators.rs | 35 |
1 files changed, 29 insertions, 6 deletions
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); } |