From dd1e6500639c25d73ff63dd8fde6ba093b2b4255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Sun, 19 Mar 2023 01:01:50 +0100 Subject: fix(runtime): Extract error code for all OS error variants (#17958) --- ext/fs/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/fs/lib.rs') diff --git a/ext/fs/lib.rs b/ext/fs/lib.rs index 386d143d2..3bad65330 100644 --- a/ext/fs/lib.rs +++ b/ext/fs/lib.rs @@ -188,8 +188,8 @@ deno_core::extension!(deno_fs, }, ); -fn default_err_mapper(err: Error, desc: String) -> Error { - Error::new(err.kind(), format!("{err}, {desc}")) +fn default_err_mapper(err: Error, desc: String) -> AnyError { + AnyError::new(Error::new(err.kind(), desc)).context(err) } #[derive(Deserialize, Default, Debug)] @@ -1017,7 +1017,7 @@ where let mut st = std::mem::zeroed(); let ret = stat(from.as_ptr(), &mut st); if ret != 0 { - return Err(err_mapper(Error::last_os_error()).into()); + return Err(err_mapper(Error::last_os_error())); } if st.st_size > 128 * 1024 { @@ -2347,9 +2347,9 @@ where let read_future = tokio::task::spawn_blocking(move || { let path = Path::new(&path); - Ok(std::fs::read(path).map(ZeroCopyBuf::from).map_err(|err| { + std::fs::read(path).map(ZeroCopyBuf::from).map_err(|err| { default_err_mapper(err, format!("readfile '{}'", path.display())) - })?) + }) }); let cancel_handle = cancel_rid.and_then(|rid| { -- cgit v1.2.3