show the full directory / file path in "directory not found" error#10430
Merged
WindSoilder merged 6 commits intonushell:mainfrom Sep 26, 2023
Merged
show the full directory / file path in "directory not found" error#10430WindSoilder merged 6 commits intonushell:mainfrom
WindSoilder merged 6 commits intonushell:mainfrom
Conversation
Member
Author
|
i'm not happy with the failing test, making this a DRAFT for now and i'll review it later, it's on the short-term TODO 👌 |
WindSoilder
reviewed
Sep 20, 2023
| code(nu::shell::directory_not_found), | ||
| help("the target directory was {0}") | ||
| )] | ||
| DirectoryNotFound(String, #[label("directory not found")] Span, Option<String>), |
Contributor
There was a problem hiding this comment.
What about changing the definition like this:
#[diagnostic(
code(nu::shell::directory_not_found),
help("{1} not found")
)]
DirectoryNotFound(#[label("directory not found")] Span, String),We already defined it as DirectoryNotFound error, I don't think we need to provide underlying IO::Error message to user.
So the error message will be something like this:
× Directory not found
╭─[entry #1:1:1]
1 │ ["a.txt"] | each {|$it| open $it}
· ─┬─
· ╰── directory not found
╰────
help: /Users/tmp/projects/rust_online_code/nushell/a.txt not foundWhich is less verbosing.
Member
Author
There was a problem hiding this comment.
should be better in b73b304 😋
just need to fix the tests now i guess 😉
Member
Author
|
yeah, the tests pass and i've updated the PR body, this is ready for review 🥳 |
Contributor
|
Having the full path is a great improvement but I don't think we should get rid of the IO Errors. They can be very helpful for diagnosing weird filesystem errors. |
hardfau1t
pushed a commit
to hardfau1t/nushell
that referenced
this pull request
Dec 14, 2023
…ushell#10430) should close nushell#10406 # Description when writing a script, with variables you try to `ls` or `open`, you will get a "directory not found" error but the variable won't be expanded and you won't be able to see which one of the variable was the issue... this PR adds this information to the error. # User-Facing Changes let's define a variable ```nushell let does_not_exist = "i_do_not_exist_in_the_current_directory" ``` ### before ```nushell > open $does_not_exist Error: nu::shell::directory_not_found × Directory not found ╭─[entry nushell#7:1:1] 1 │ open $does_not_exist · ───────┬─────── · ╰── directory not found ╰──── ``` ```nushell > ls $does_not_exist Error: nu:🐚:directory_not_found × Directory not found ╭─[entry nushell#8:1:1] 1 │ ls $does_not_exist · ───────┬─────── · ╰── directory not found ╰──── ``` ### after ```nushell > open $does_not_exist Error: nu:🐚:directory_not_found × Directory not found ╭─[entry nushell#3:1:1] 1 │ open $does_not_exist · ───────┬─────── · ╰── directory not found ╰──── help: /home/amtoine/documents/repos/github.com/amtoine/nushell/i_do_not_exist_in_the_current_directory does not exist ``` ```nushell > ls $does_not_exist Error: nu:🐚:directory_not_found × Directory not found ╭─[entry nushell#4:1:1] 1 │ ls $does_not_exist · ───────┬─────── · ╰── directory not found ╰──── help: /home/amtoine/documents/repos/github.com/amtoine/nushell/i_do_not_exist_in_the_current_directory does not exist ``` # Tests + Formatting shouldn't harm anything 🤞 # After Submitting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
should close #10406
Description
when writing a script, with variables you try to
lsoropen, you will get a "directory not found" error but the variable won't be expanded and you won't be able to see which one of the variable was the issue...this PR adds this information to the error.
User-Facing Changes
let's define a variable
before
after
Tests + Formatting
shouldn't harm anything 🤞
After Submitting