mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:05:47 +02:00
show the full directory / file path in "directory not found" error (#10430)
should close https://github.com/nushell/nushell/issues/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:🐚:directory_not_found × Directory not found ╭─[entry #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 #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 #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 #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 commit is contained in:
@ -801,8 +801,8 @@ pub enum ShellError {
|
||||
///
|
||||
/// Make sure the directory in the error message actually exists before trying again.
|
||||
#[error("Directory not found")]
|
||||
#[diagnostic(code(nu::shell::directory_not_found))]
|
||||
DirectoryNotFound(#[label("directory not found")] Span, #[help] Option<String>),
|
||||
#[diagnostic(code(nu::shell::directory_not_found), help("{1} does not exist"))]
|
||||
DirectoryNotFound(#[label("directory not found")] Span, String),
|
||||
|
||||
/// Attempted to perform an operation on a directory that doesn't exist.
|
||||
///
|
||||
|
Reference in New Issue
Block a user