Skip to content

Commit 792598c

Browse files
Binlogodjc
authored andcommitted
opt(err): show renaming file error source
chore: fix ci windows build issue
1 parent f5cea1a commit 792598c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/errors.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
use std::ffi::OsString;
44
use std::fmt::Debug;
5-
#[cfg(not(windows))]
65
use std::io;
76
use std::io::Write;
87
use std::path::PathBuf;
@@ -77,6 +76,13 @@ pub enum RustupError {
7776
RemovingDirectory { name: &'static str, path: PathBuf },
7877
#[error("could not remove '{name}' file: '{}'", .path.display())]
7978
RemovingFile { name: &'static str, path: PathBuf },
79+
#[error("could not rename '{name}' file from '{src}' to '{dest}': {source}")]
80+
RenamingFile {
81+
name: &'static str,
82+
src: PathBuf,
83+
dest: PathBuf,
84+
source: io::Error,
85+
},
8086
#[error("{}", component_unavailable_msg(.components, .manifest, .toolchain))]
8187
RequestedComponentsUnavailable {
8288
components: Vec<Component>,

src/utils/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,13 +471,14 @@ where
471471
},
472472
},
473473
)
474-
.with_context(|| {
475-
format!(
476-
"could not rename {} file from '{}' to '{}'",
474+
.map_err(|e| {
475+
RustupError::RenamingFile {
477476
name,
478-
src.display(),
479-
dest.display()
480-
)
477+
src: PathBuf::from(src),
478+
dest: PathBuf::from(dest),
479+
source: e.error,
480+
}
481+
.into()
481482
})
482483
}
483484

0 commit comments

Comments
 (0)