Continue and Break on Try/Catch (#7683)

Co-authored-by: sholderbach <sholderbach@users.noreply.github.com>
Fixes https://github.com/nushell/nushell/issues/7656
This commit is contained in:
Amirhossein Akhlaghpour
2023-01-05 15:41:51 -05:00
committed by GitHub
parent 771270d526
commit 9b617de6f0
2 changed files with 59 additions and 0 deletions

View File

@ -57,6 +57,13 @@ impl Command for Try {
match result {
Err(error) | Ok(PipelineData::Value(Value::Error { error }, ..)) => {
if let nu_protocol::ShellError::Break(_) = error {
return Err(error);
} else if let nu_protocol::ShellError::Continue(_) = error {
return Err(error);
} else if let nu_protocol::ShellError::Return(_, _) = error {
return Err(error);
}
if let Some(catch_block) = catch_block {
let catch_block = engine_state.get_block(catch_block.block_id);
let err_value = Value::Error { error };