fix(core): improve error handling for copy and remove (#18656)
This commit is contained in:
parent
f670e7469f
commit
13925ba576
13
packages/nx/src/native/cache/file_ops.rs
vendored
13
packages/nx/src/native/cache/file_ops.rs
vendored
@ -1,9 +1,14 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use fs_extra::error::ErrorKind;
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn remove(src: String) -> anyhow::Result<()> {
|
pub fn remove(src: String) -> anyhow::Result<()> {
|
||||||
fs_extra::remove_items(&[src]).map_err(anyhow::Error::from)
|
fs_extra::remove_items(&[src]).map_err(|err| match err.kind {
|
||||||
|
ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind),
|
||||||
|
_ => anyhow::Error::new(err),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
@ -19,7 +24,11 @@ pub fn copy(src: String, dest: String) -> anyhow::Result<()> {
|
|||||||
fs::create_dir_all(dest_parent)?;
|
fs::create_dir_all(dest_parent)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
fs_extra::copy_items(&[src], dest_parent, ©_options)?;
|
fs_extra::copy_items(&[src], dest_parent, ©_options).map_err(|err| match err.kind {
|
||||||
|
ErrorKind::Io(err_kind) => anyhow::Error::new(err_kind),
|
||||||
|
_ => anyhow::Error::new(err),
|
||||||
|
})?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user