Skip to content

Commit 640bedc

Browse files
authored
Merge pull request #2496 from eidenar/double_error_fix
Fix double error label for certain error types
2 parents bde7f78 + 3cd75c8 commit 640bedc

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/cli/rustup_mode.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,22 @@ pub fn main() -> Result<utils::ExitCode> {
9494
}
9595
return Ok(utils::ExitCode(0));
9696
}
97-
Err(clap::Error {
98-
kind: MissingArgumentOrSubcommand,
99-
message,
100-
..
101-
}) => {
102-
writeln!(process().stdout().lock(), "{}", message)?;
103-
return Ok(utils::ExitCode(1));
104-
}
105-
Err(e) => Err(e),
97+
98+
Err(e) => match &e {
99+
clap::Error { kind, message, .. } => {
100+
if [
101+
InvalidSubcommand,
102+
UnknownArgument,
103+
MissingArgumentOrSubcommand,
104+
]
105+
.contains(kind)
106+
{
107+
writeln!(process().stdout().lock(), "{}", message)?;
108+
return Ok(utils::ExitCode(1));
109+
}
110+
Err(e)
111+
}
112+
},
106113
}?;
107114
let verbose = matches.is_present("verbose");
108115
let quiet = matches.is_present("quiet");

0 commit comments

Comments
 (0)