Skip to content

Commit 13925ba

Browse files
authored
fix(core): improve error handling for copy and remove (#18656)
1 parent f670e74 commit 13925ba

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/nx/src/native/cache/file_ops.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
use std::fs;
22
use std::path::PathBuf;
33

4+
use fs_extra::error::ErrorKind;
5+
46
#[napi]
57
pub fn remove(src: String) -> anyhow::Result<()> {
6-
fs_extra::remove_items(&[src]).map_err(anyhow::Error::from)
8+
fs_extra::remove_items(&[src]).map_err(|err| match err.kind {
9+
ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind),
10+
_ => anyhow::Error::new(err),
11+
})
712
}
813

914
#[napi]
@@ -19,7 +24,11 @@ pub fn copy(src: String, dest: String) -> anyhow::Result<()> {
1924
fs::create_dir_all(dest_parent)?;
2025
}
2126

22-
fs_extra::copy_items(&[src], dest_parent, &copy_options)?;
27+
fs_extra::copy_items(&[src], dest_parent, &copy_options).map_err(|err| match err.kind {
28+
ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind),
29+
_ => anyhow::Error::new(err),
30+
})?;
31+
2332
Ok(())
2433
}
2534

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy