mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
WIP fix for the error bubbling (#1597)
This commit is contained in:
parent
928188b18e
commit
ee778d2b03
@ -152,7 +152,8 @@ pub(crate) fn run_internal_command(
|
||||
value: UntaggedValue::Error(err),
|
||||
..
|
||||
})) => {
|
||||
context.error(err);
|
||||
context.error(err.clone());
|
||||
yield Err(err);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@ impl PerItemCommand for Each {
|
||||
tag
|
||||
} => {
|
||||
let mut context = Context::from_raw(&raw_args, ®istry);
|
||||
let input_clone = input.clone();
|
||||
let input_stream = async_stream! {
|
||||
yield Ok(input.clone())
|
||||
}.to_input_stream();
|
||||
@ -53,12 +54,17 @@ impl PerItemCommand for Each {
|
||||
ClassifiedPipeline::new(block.clone(), None),
|
||||
&mut context,
|
||||
Some(input_stream),
|
||||
&Scope::empty(),
|
||||
&Scope::new(input_clone),
|
||||
).await;
|
||||
|
||||
match result {
|
||||
Ok(Some(v)) => {
|
||||
let results: Vec<Value> = v.collect().await;
|
||||
let errors = context.get_errors();
|
||||
if let Some(error) = errors.first() {
|
||||
yield Err(error.clone());
|
||||
return;
|
||||
}
|
||||
|
||||
for result in results {
|
||||
yield Ok(ReturnSuccess::Value(result));
|
||||
|
@ -47,7 +47,7 @@ impl PerItemCommand for AliasCommand {
|
||||
let raw_args = raw_args.clone();
|
||||
let block = self.block.clone();
|
||||
|
||||
let mut scope = Scope::empty();
|
||||
let mut scope = Scope::it_value(input.clone());
|
||||
if let Some(positional) = &call_info.args.positional {
|
||||
for (pos, arg) in positional.iter().enumerate() {
|
||||
scope = scope.set_var(self.args[pos].to_string(), arg.clone());
|
||||
@ -70,6 +70,11 @@ impl PerItemCommand for AliasCommand {
|
||||
match result {
|
||||
Ok(Some(v)) => {
|
||||
let results: Vec<Value> = v.collect().await;
|
||||
let errors = context.get_errors();
|
||||
if let Some(error) = errors.first() {
|
||||
yield Err(error.clone());
|
||||
return;
|
||||
}
|
||||
|
||||
for result in results {
|
||||
yield Ok(ReturnSuccess::Value(result));
|
||||
|
@ -147,6 +147,10 @@ impl Context {
|
||||
self.with_errors(|errors| errors.push(error))
|
||||
}
|
||||
|
||||
pub(crate) fn get_errors(&self) -> Vec<ShellError> {
|
||||
self.current_errors.lock().clone()
|
||||
}
|
||||
|
||||
pub(crate) fn maybe_print_errors(&mut self, source: Text) -> bool {
|
||||
let errors = self.current_errors.clone();
|
||||
let mut errors = errors.lock();
|
||||
|
Loading…
Reference in New Issue
Block a user