Skip to content

Commit ab648dc

Browse files
authored
Merge pull request #3041 from olalonde/improve-override-file-errors
Improve error message when there is an error caused by override file
2 parents 6bc5d2c + f427111 commit ab648dc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/config.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,16 @@ impl Cfg {
673673
};
674674

675675
if let Ok(contents) = contents {
676-
let override_file = Cfg::parse_override_file(contents, parse_mode)?;
676+
let add_file_context = || format!("in {}", toolchain_file.to_string_lossy());
677+
let override_file = Cfg::parse_override_file(contents, parse_mode)
678+
.with_context(add_file_context)?;
677679
if let Some(toolchain_name) = &override_file.toolchain.channel {
678-
let all_toolchains = self.list_toolchains()?;
680+
let all_toolchains = self.list_toolchains().with_context(add_file_context)?;
679681
if !all_toolchains.iter().any(|s| s == toolchain_name) {
680682
// The given name is not resolvable as a toolchain, so
681683
// instead check it's plausible for installation later
682-
dist::validate_channel_name(toolchain_name)?;
684+
dist::validate_channel_name(toolchain_name)
685+
.with_context(add_file_context)?;
683686
}
684687
}
685688

0 commit comments

Comments
 (0)