Skip to content

make "can't follow stream paths" error a bit better - #10569

Merged
sholderbach merged 4 commits into
nushell:mainfrom
amtoine:better-cant-follow-stream-path-error
Oct 3, 2023
Merged

sholderbach merged 4 commits into
nushell:mainfrom
amtoine:better-cant-follow-stream-path-error

Conversation

@amtoine

@amtoine amtoine commented Oct 1, 2023 •

Copy link
Copy Markdown
Member

related to

might be able to close #8639?

Description

"can't follow stream paths" errors have always been a bit scary and obnoxious because they give no information about what happens...

in this PR i try to slightly improve the error message by telling if the stream was empty or not and give span information when available.

User-Facing Changes

> update value (get value)
Error: nu::shell::incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[entry #1:1:1]
 1 │ update value (get value)
   ·               ─┬─
   ·                ╰── empty pipeline doesn't support cell paths
   ╰────
> ^echo "foo" | get 0
Error: nu::shell::incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[entry #2:1:1]
 1 │ ^echo "foo" | get 0
   ·  ──┬─
   ·    ╰── external stream doesn't support cell paths
   ╰────

Tests + Formatting

After Submitting

errors look like
```nushell
> update value (get value)
Error: nu::shell::io_error

  × I/O error
  help: can't follow path '[String { val: "value", span: Span { start: 243376, end: 243381 }, optional: false }]' in empty stream
```
```nushell
> ^echo "foo" | get 0
Error: nu::shell::io_error

  × I/O error
   ╭─[entry #3:1:1]
 1 │ ^echo "foo" | get 0
   ·  ──┬─
   ·    ╰── can't follow path '[Int { val: 0, span: Span { start: 243417, end: 243418 }, optional: false }]' in external stream
   ╰────
```
errors look like
```nushell
> update value (get value)
Error: nu::shell::io_error

  × I/O error
  help: can't follow path 'value' in empty stream
```
```nushell
> ^echo "foo" | get 0
Error: nu::shell::io_error

  × I/O error
   ╭─[entry #2:1:1]
 1 │ ^echo "foo" | get 0
   ·  ──┬─
   ·    ╰── can't follow path '0' in external stream
   ╰────
```

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spanning this error.

I think IOError is misleading here, as the failing operation is the look up. Our closest existing variant may be IncompatiblePathAccess, that would need some adjustment in other places if you want to include the path as well.

@amtoine

amtoine commented Oct 3, 2023

Copy link
Copy Markdown
Member Author

@sholderbach
i've used IncompatiblePathAccess errors in 4400930 and did update the PR description 😉

@sholderbach sholderbach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sholderbach
sholderbach merged commit f481879 into nushell:main Oct 3, 2023
@amtoine
amtoine deleted the better-cant-follow-stream-path-error branch October 3, 2023 17:00
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
related to
- nushell#9373
- nushell#8639

might be able to close nushell#8639? 

# Description
"can't follow stream paths" errors have always been a bit scary and
obnoxious because they give no information about what happens...

in this PR i try to slightly improve the error message by telling if the
stream was empty or not and give span information when available.

# User-Facing Changes
```nushell
> update value (get value)
Error: nu::shell::incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[entry #1:1:1]
 1 │ update value (get value)
   ·               ─┬─
   ·                ╰── empty pipeline doesn't support cell paths
   ╰────
```
```nushell
> ^echo "foo" | get 0
Error: nu:🐚:incompatible_path_access

  × Data cannot be accessed with a cell path
   ╭─[entry nushell#2:1:1]
 1 │ ^echo "foo" | get 0
   ·  ──┬─
   ·    ╰── external stream doesn't support cell paths
   ╰────
```

# Tests + Formatting

# After Submitting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Io_error: Can't follow stream path

2 participants