diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2024-10-15 15:36:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 15:36:11 -0700 |
commit | 82d13fd45b6fa8da5d390e26a349522e93811639 (patch) | |
tree | 2278d45f31961df69ea19678d5334f73d2bbc8e7 /ext/io/lib.rs | |
parent | ee904ec06c1a3b3d4e4a87898e777e2f9b587b07 (diff) |
refactor(ext/io): use concrete error types (#26187)
Diffstat (limited to 'ext/io/lib.rs')
-rw-r--r-- | ext/io/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/io/lib.rs b/ext/io/lib.rs index a07d64ae3..5d183aa46 100644 --- a/ext/io/lib.rs +++ b/ext/io/lib.rs @@ -1,6 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -use deno_core::error::AnyError; use deno_core::op2; use deno_core::unsync::spawn_blocking; use deno_core::unsync::TaskQueue; @@ -48,6 +47,7 @@ use winapi::um::processenv::GetStdHandle; #[cfg(windows)] use winapi::um::winbase; +use deno_core::futures::TryFutureExt; #[cfg(windows)] use parking_lot::Condvar; #[cfg(windows)] @@ -348,13 +348,13 @@ where RcRef::map(self, |r| &r.stream).borrow_mut() } - async fn write(self: Rc<Self>, data: &[u8]) -> Result<usize, AnyError> { + async fn write(self: Rc<Self>, data: &[u8]) -> Result<usize, io::Error> { let mut stream = self.borrow_mut().await; let nwritten = stream.write(data).await?; Ok(nwritten) } - async fn shutdown(self: Rc<Self>) -> Result<(), AnyError> { + async fn shutdown(self: Rc<Self>) -> Result<(), io::Error> { let mut stream = self.borrow_mut().await; stream.shutdown().await?; Ok(()) @@ -396,7 +396,7 @@ where self.cancel_handle.cancel() } - async fn read(self: Rc<Self>, data: &mut [u8]) -> Result<usize, AnyError> { + async fn read(self: Rc<Self>, data: &mut [u8]) -> Result<usize, io::Error> { let mut rd = self.borrow_mut().await; let nread = rd.read(data).try_or_cancel(self.cancel_handle()).await?; Ok(nread) @@ -417,7 +417,7 @@ impl Resource for ChildStdinResource { deno_core::impl_writable!(); fn shutdown(self: Rc<Self>) -> AsyncResult<()> { - Box::pin(self.shutdown()) + Box::pin(self.shutdown().map_err(|e| e.into())) } } @@ -1010,7 +1010,7 @@ pub fn op_print( state: &mut OpState, #[string] msg: &str, is_err: bool, -) -> Result<(), AnyError> { +) -> Result<(), deno_core::error::AnyError> { let rid = if is_err { 2 } else { 1 }; FileResource::with_file(state, rid, move |file| { Ok(file.write_all_sync(msg.as_bytes())?) |