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

@ -288,7 +288,10 @@ impl NuDataFrame {
.collect::<Vec<String>>();
let option = did_you_mean(&possibilities, column).unwrap_or_else(|| column.to_string());
ShellError::DidYouMean(option, span)
ShellError::DidYouMean {
suggestion: option,
span,
}
})?;
let df = DataFrame::new(vec![s.clone()]).map_err(|e| {

View File

@ -24,10 +24,10 @@ impl NuDataFrame {
match right {
Value::CustomValue { val: rhs, .. } => {
let rhs = rhs.as_any().downcast_ref::<NuDataFrame>().ok_or_else(|| {
ShellError::DowncastNotPossible(
"Unable to create dataframe".to_string(),
rhs_span,
)
ShellError::DowncastNotPossible {
msg: "Unable to create dataframe".to_string(),
span: rhs_span,
}
})?;
match (self.is_series(), rhs.is_series()) {

View File

@ -57,7 +57,10 @@ fn compute_with_value(
match right {
Value::CustomValue { val: rhs, .. } => {
let rhs = rhs.as_any().downcast_ref::<NuExpression>().ok_or_else(|| {
ShellError::DowncastNotPossible("Unable to create expression".to_string(), rhs_span)
ShellError::DowncastNotPossible {
msg: "Unable to create expression".into(),
span: rhs_span,
}
})?;
match rhs.as_ref() {