Convert more ShellError variants to named fields (#11222)

# Description

Convert errors to named fields:
* NeedsPositiveValue
* MissingConfigValue
* UnsupportedConfigValue
* DowncastNotPossible
* NonUtf8Custom
* NonUtf8
* DidYouMeanCustom
* DidYouMean
* ReadingFile
* RemoveNotPossible
* ChangedModifiedTimeNotPossible
* ChangedAccessTimeNotPossible

Part of #10700
This commit is contained in:
Eric Hodel
2023-12-04 01:19:32 -08:00
committed by GitHub
parent b227eea668
commit 67eec92e76
26 changed files with 299 additions and 208 deletions

View File

@ -52,11 +52,11 @@ impl Command for HideEnv {
.cloned()
.collect();
if let Some(closest_match) = did_you_mean(&all_names, &name.item) {
return Err(ShellError::DidYouMeanCustom(
format!("Environment variable '{}' not found", name.item),
closest_match,
name.span,
));
return Err(ShellError::DidYouMeanCustom {
msg: format!("Environment variable '{}' not found", name.item),
suggestion: closest_match,
span: name.span,
});
} else {
return Err(ShellError::EnvVarNotFoundAtRuntime {
envvar_name: name.item,

View File

@ -96,7 +96,9 @@ impl Command for OverlayUse {
if let Some(name) = os_str.to_str() {
name.to_string()
} else {
return Err(ShellError::NonUtf8(name_arg.span));
return Err(ShellError::NonUtf8 {
span: name_arg.span,
});
}
} else {
return Err(ShellError::OverlayNotFoundAtRuntime {