Fix the panic running a bad alias (#1624)

This commit is contained in:
Jonathan Turner 2020-04-21 16:11:34 +12:00 committed by GitHub
parent 0f7b270740
commit ce0231049e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,7 @@ impl PerItemCommand for AliasCommand {
Ok(stream) if stream.is_empty() => { Ok(stream) if stream.is_empty() => {
yield Err(ShellError::labeled_error( yield Err(ShellError::labeled_error(
"Expected a block", "Expected a block",
"each needs a block", "alias needs a block",
tag, tag,
)); ));
} }
@ -79,12 +79,26 @@ impl PerItemCommand for AliasCommand {
} }
let errors = context.get_errors(); let errors = context.get_errors();
if let Some(error) = errors.first() { if let Some(x) = errors.first() {
yield Err(error.clone()); //yield Err(error.clone());
yield Err(ShellError::labeled_error_with_secondary(
"Alias failed to run",
"alias failed to run",
tag.clone(),
x.to_string(),
tag
));
} }
} }
Err(e) => { Err(e) => {
yield Err(e); //yield Err(e);
yield Err(ShellError::labeled_error_with_secondary(
"Alias failed to run",
"alias failed to run",
tag.clone(),
e.to_string(),
tag
));
} }
} }
}; };