1
0
mirror of https://github.com/nushell/nushell.git synced 2025-07-10 11:27:02 +02:00

Convert ShellError::AliasNotFound to named fields ()

# Description

Part of 

# User-Facing Changes

None

# Tests + Formatting

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`

# After Submitting

N/A
This commit is contained in:
Eric Hodel
2023-11-21 00:24:08 -08:00
committed by GitHub
parent 1b54dd5418
commit 0578cf85ac
3 changed files with 11 additions and 8 deletions
crates
nu-command
nu-protocol

@ -89,7 +89,7 @@ You can also learn more at https://www.nushell.sh/book/"#;
} else { } else {
let result = help_aliases(engine_state, stack, call); let result = help_aliases(engine_state, stack, call);
let result = if let Err(ShellError::AliasNotFound(_)) = result { let result = if let Err(ShellError::AliasNotFound { .. }) = result {
help_commands(engine_state, stack, call) help_commands(engine_state, stack, call)
} else { } else {
result result

@ -119,15 +119,15 @@ pub fn help_aliases(
} }
let Some(alias) = engine_state.find_decl(name.as_bytes(), &[]) else { let Some(alias) = engine_state.find_decl(name.as_bytes(), &[]) else {
return Err(ShellError::AliasNotFound(span( return Err(ShellError::AliasNotFound {
&rest.iter().map(|r| r.span).collect::<Vec<Span>>(), span: span(&rest.iter().map(|r| r.span).collect::<Vec<Span>>()),
))); });
}; };
let Some(alias) = engine_state.get_decl(alias).as_alias() else { let Some(alias) = engine_state.get_decl(alias).as_alias() else {
return Err(ShellError::AliasNotFound(span( return Err(ShellError::AliasNotFound {
&rest.iter().map(|r| r.span).collect::<Vec<Span>>(), span: span(&rest.iter().map(|r| r.span).collect::<Vec<Span>>()),
))); });
}; };
let alias_expansion = let alias_expansion =

@ -701,7 +701,10 @@ pub enum ShellError {
/// The alias does not exist in the current scope. It might exist in another scope or overlay or be hidden. /// The alias does not exist in the current scope. It might exist in another scope or overlay or be hidden.
#[error("Alias not found")] #[error("Alias not found")]
#[diagnostic(code(nu::shell::alias_not_found))] #[diagnostic(code(nu::shell::alias_not_found))]
AliasNotFound(#[label("alias not found")] Span), AliasNotFound {
#[label("alias not found")]
span: Span,
},
/// Failed to find a file during a nushell operation. /// Failed to find a file during a nushell operation.
/// ///