tweaked the error handling to show specific errors (#3367)

This commit is contained in:
Darren Schroeder 2021-04-30 09:24:06 -05:00 committed by GitHub
parent 3792562046
commit a8f555856a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -199,7 +199,8 @@ fn spawn(
trace!(target: "nu::run::external", "built command {:?}", process); trace!(target: "nu::run::external", "built command {:?}", process);
// TODO Switch to async_std::process once it's stabilized // TODO Switch to async_std::process once it's stabilized
if let Ok(mut child) = process.spawn() { match process.spawn() {
Ok(mut child) => {
let (tx, rx) = mpsc::sync_channel(0); let (tx, rx) = mpsc::sync_channel(0);
let mut stdin = child.stdin.take(); let mut stdin = child.stdin.take();
@ -280,7 +281,9 @@ fn spawn(
Ok(line) => match line { Ok(line) => match line {
StringOrBinary::String(s) => { StringOrBinary::String(s) => {
let result = stdout_read_tx.send(Ok(Value { let result = stdout_read_tx.send(Ok(Value {
value: UntaggedValue::Primitive(Primitive::String(s.clone())), value: UntaggedValue::Primitive(Primitive::String(
s.clone(),
)),
tag: stdout_name_tag.clone(), tag: stdout_name_tag.clone(),
})); }));
@ -434,12 +437,12 @@ fn spawn(
let stream = ChannelReceiver::new(rx); let stream = ChannelReceiver::new(rx);
Ok(stream.to_input_stream()) Ok(stream.to_input_stream())
} else { }
Err(ShellError::labeled_error( Err(e) => Err(ShellError::labeled_error(
"Failed to spawn process", format!("{}", e),
"failed to spawn", "failed to spawn",
&command.name_tag, &command.name_tag,
)) )),
} }
} }