diff --git a/crates/nu-command/src/filters/transpose.rs b/crates/nu-command/src/filters/transpose.rs index 813a4733b2..873a21c90d 100644 --- a/crates/nu-command/src/filters/transpose.rs +++ b/crates/nu-command/src/filters/transpose.rs @@ -175,6 +175,12 @@ pub fn transpose( let metadata = input.metadata(); let input: Vec<_> = input.into_iter().collect(); + // Ensure error values are propagated + for i in input.iter() { + if let Value::Error { .. } = i { + return Ok(i.clone().into_pipeline_data_with_metadata(metadata)); + } + } let descs = get_columns(&input); diff --git a/crates/nu-command/tests/commands/transpose.rs b/crates/nu-command/tests/commands/transpose.rs index a155319bfc..29a7632af3 100644 --- a/crates/nu-command/tests/commands/transpose.rs +++ b/crates/nu-command/tests/commands/transpose.rs @@ -20,3 +20,15 @@ fn row_but_all() { assert!(actual.out.contains("foo: [1, 2]")); } + +#[test] +fn throw_inner_error() { + let error_msg = "This message should show up"; + let error = format!("(error make {{ msg: \"{}\" }})", error_msg); + let actual = nu!(format!( + "[[key value]; [foo 1] [foo 2] [{} 3]] | transpose", + error + )); + + assert!(actual.err.contains(error.as_str())); +}