Repository navigation
Closed
Labels
A:error-handlingHow errors in externals/nu code are caught or handled programmatically (see also unhelpful-error)category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedstatus:needs-triageAn issue that hasn't had any proper look
Milestone
Description
Potentially related (from @blm768):
Describe the bug
I tried this code:
[0] | each { |_|
[0] | each { |_|
non-existent-command
}
}If you put it into a file and run with nu you'll see the output:
╭───┬───────────────╮
│ 0 │ [list 1 item] │
╰───┴───────────────╯
If you put | debug after the outermost each you'll see:
╭───┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 0 │ [EvalBlockWithInput(Span { start: 126475, end: 126476 }, [ExternalCommand { label: "executable was not found", help: "No such file or directory (os error │
│ │ 2)", span: Span { start: 126499, end: 126519 } }])] │
╰───┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
And if you put smth like | to json after the outermost each you'll see the error:
Details
Error: nu::shell::eval_block_with_input
× Eval block failed with pipeline input
╭─[/home/veetaha/work/elastio/dbg.nu:5:1]
5 │ [0] | each { |_|
6 │ [0] | each { |_|
· ┬
· ╰── source value
7 │ non-existent-command
╰────
Error: nu::shell::external_command
× External command failed
╭─[/home/veetaha/work/elastio/dbg.nu:6:1]
6 │ [0] | each { |_|
7 │ non-existent-command
· ──────────┬─────────
· ╰── executable was not found
8 │ }
╰────
help: No such file or directory (os error 2)
Expected behavior
I expected to see the "executable not found" error no matter what happens with the resulting value. The error should be propagated even if there is no | to json or similar at the end.
Configuration
| key | value |
|---|---|
| version | 0.87.1 |
| branch | |
| commit_hash | 3d63149 |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.71.1 (eb26296b5 2023-08-03) |
| rust_channel | 1.71.1-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.71.1 (7f1d04c00 2023-07-29) |
| build_time | 2023-11-18 18:51:59 +00:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, static-link-openssl, trash, which, zip |
| installed_plugins | from eml, from ics, from ini, from vcf |
Reacted by Mauricio Scheffer
Metadata
Metadata
Assignees
Labels
A:error-handlingHow errors in externals/nu code are caught or handled programmatically (see also unhelpful-error)category:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedstatus:needs-triageAn issue that hasn't had any proper look
Activity
amtoine commentedon Dec 4, 2023
yeah, not sure what's happening there 🤔
looks like errors are partially values and partially thrown??
if you put it in a variable, it's fine
if you look at the variable, it's fine
$foobut if you try to look at the list item, now it throws the error 😮
blm768 commentedon Dec 11, 2023
Potentially related: #10176, #8615.
Prevent `each` from swallowing errors when `eval_block` returns a `Li…