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

@ -82,12 +82,16 @@ impl Command for Du {
let max_depth: Option<Spanned<i64>> = call.get_flag(engine_state, stack, "max-depth")?;
if let Some(ref max_depth) = max_depth {
if max_depth.item < 0 {
return Err(ShellError::NeedsPositiveValue(max_depth.span));
return Err(ShellError::NeedsPositiveValue {
span: max_depth.span,
});
}
}
if let Some(ref min_size) = min_size {
if min_size.item < 0 {
return Err(ShellError::NeedsPositiveValue(min_size.span));
return Err(ShellError::NeedsPositiveValue {
span: min_size.span,
});
}
}
let current_dir = current_dir(engine_state, stack)?;