fix panic with lines on an error (#9967)

should close https://github.com/nushell/nushell/issues/9965

# Description
this PR implements the `todo!()` left in `lines`.

# User-Facing Changes
### before
```nushell
> open . | lines
thread 'main' panicked at 'not yet implemented', crates/nu-command/src/filters/lines.rs:248:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```

### after
```nushell
> open . | lines
Error: nu:🐚:io_error

  × I/O error
  help: Is a directory (os error 21)
```

# Tests + Formatting
- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
-  `toolkit test`
-  `toolkit test stdlib`

this PR adds the `lines_on_error` test to make sure this does not happen
again 😌

# After Submitting
This commit is contained in:
Antoine Stevan 2023-08-09 14:12:58 +02:00 committed by GitHub
parent 0674d4960b
commit 202dfdaee2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -245,7 +245,7 @@ impl Iterator for RawStreamLinesAdapter {
}
}
}
Err(_) => todo!(),
Err(err) => return Some(Err(err)),
}
} else {
self.inner_complete = true;

View File

@ -61,3 +61,11 @@ fn lines_mixed_line_endings() {
assert_eq!(actual.out, "3");
}
#[cfg(not(windows))]
#[test]
fn lines_on_error() {
let actual = nu!("open . | lines");
assert!(actual.err.contains("Is a directory"));
}