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

@ -145,10 +145,10 @@ fn from_csv(
let unicode_sep = u32::from_str_radix(&sep, 16);
char::from_u32(unicode_sep.unwrap_or(b'\x1f' as u32)).unwrap_or(',')
} else {
return Err(ShellError::NonUtf8Custom(
"separator should be a single char or a 4-byte unicode".to_string(),
call.span(),
));
return Err(ShellError::NonUtf8Custom {
msg: "separator should be a single char or a 4-byte unicode".into(),
span: call.span(),
});
}
}
None => ',',

View File

@ -390,7 +390,7 @@ fn to_xml(
let s = if let Ok(s) = String::from_utf8(b) {
s
} else {
return Err(ShellError::NonUtf8(head));
return Err(ShellError::NonUtf8 { span: head });
};
Ok(Value::string(s, head).into_pipeline_data())
})