Make group-by return errors in closure (#12508)

# Description
When a closure if provided to `group-by`, errors that occur in the
closure are currently ignored. That is, `group-by` will fall back and
use the `"error"` key if an error occurs. For example, the code snippet
below will group all `ls` entries under the `"error"` column.
```nushell
ls | group-by { get nope } 
```

This PR changes `group-by` to instead bubble up any errors triggered
inside the closure. In addition, this PR also does some refactoring and
cleanup inside `group-by`.

# User-Facing Changes
Errors are now returned from the closure provided to `group-by` instead
of falling back to the `"error"` group/key.
This commit is contained in:
Ian Manske
2024-04-16 19:52:21 +00:00
committed by GitHub
parent a7a5ec31be
commit cc781a1ecd
2 changed files with 76 additions and 132 deletions

View File

@ -53,9 +53,7 @@ fn errors_if_given_unknown_column_name() {
"#
)));
assert!(actual
.err
.contains("requires a table with one value for grouping"));
assert!(actual.err.contains("can't convert list<string> to string"));
}
#[test]