mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 14:48:44 +02:00
update miette and switch to GenericErrors (#5222)
This commit is contained in:
@ -193,7 +193,7 @@ fn from_eml(
|
||||
.with_body_preview(body_preview)
|
||||
.parse()
|
||||
.map_err(|_| {
|
||||
ShellError::CantConvert("structured eml data".into(), "string".into(), head)
|
||||
ShellError::CantConvert("structured eml data".into(), "string".into(), head, None)
|
||||
})?;
|
||||
|
||||
let mut collected = IndexMap::new();
|
||||
|
@ -137,6 +137,7 @@ fn convert_nujson_to_value(value: &nu_json::Value, span: Span) -> Value {
|
||||
"i64 sized integer".into(),
|
||||
"value larger than i64".into(),
|
||||
span,
|
||||
None,
|
||||
),
|
||||
}
|
||||
} else {
|
||||
@ -188,10 +189,11 @@ fn convert_string_to_value(string_input: String, span: Span) -> Result<Value, Sh
|
||||
nu_json::Error::Syntax(_, row, col) => {
|
||||
let label = x.to_string();
|
||||
let label_span = convert_row_column_to_span(row, col, &string_input);
|
||||
Err(ShellError::SpannedLabeledErrorRelated(
|
||||
Err(ShellError::GenericError(
|
||||
"Error while parsing JSON text".into(),
|
||||
"error parsing JSON text".into(),
|
||||
span,
|
||||
Some(span),
|
||||
None,
|
||||
vec![ShellError::OutsideSpannedLabeledError(
|
||||
string_input,
|
||||
"Error while parsing JSON text".into(),
|
||||
@ -204,6 +206,7 @@ fn convert_string_to_value(string_input: String, span: Span) -> Result<Value, Sh
|
||||
format!("structured json data ({})", x),
|
||||
"string".into(),
|
||||
span,
|
||||
None,
|
||||
)),
|
||||
},
|
||||
}
|
||||
|
@ -95,10 +95,11 @@ impl Command for FromNuon {
|
||||
|
||||
if let Some(pipeline) = block.pipelines.get(1) {
|
||||
if let Some(expr) = pipeline.expressions.get(0) {
|
||||
return Err(ShellError::SpannedLabeledErrorRelated(
|
||||
return Err(ShellError::GenericError(
|
||||
"error when loading nuon text".into(),
|
||||
"could not load nuon text".into(),
|
||||
head,
|
||||
Some(head),
|
||||
None,
|
||||
vec![ShellError::OutsideSpannedLabeledError(
|
||||
string_input,
|
||||
"error when loading".into(),
|
||||
@ -107,14 +108,17 @@ impl Command for FromNuon {
|
||||
)],
|
||||
));
|
||||
} else {
|
||||
return Err(ShellError::SpannedLabeledErrorRelated(
|
||||
return Err(ShellError::GenericError(
|
||||
"error when loading nuon text".into(),
|
||||
"could not load nuon text".into(),
|
||||
head,
|
||||
vec![ShellError::SpannedLabeledError(
|
||||
Some(head),
|
||||
None,
|
||||
vec![ShellError::GenericError(
|
||||
"error when loading".into(),
|
||||
"excess values when loading".into(),
|
||||
head,
|
||||
Some(head),
|
||||
None,
|
||||
Vec::new(),
|
||||
)],
|
||||
));
|
||||
}
|
||||
@ -131,10 +135,11 @@ impl Command for FromNuon {
|
||||
let mut pipeline = block.pipelines.remove(0);
|
||||
|
||||
if let Some(expr) = pipeline.expressions.get(1) {
|
||||
return Err(ShellError::SpannedLabeledErrorRelated(
|
||||
return Err(ShellError::GenericError(
|
||||
"error when loading nuon text".into(),
|
||||
"could not load nuon text".into(),
|
||||
head,
|
||||
Some(head),
|
||||
None,
|
||||
vec![ShellError::OutsideSpannedLabeledError(
|
||||
string_input,
|
||||
"error when loading".into(),
|
||||
@ -157,10 +162,11 @@ impl Command for FromNuon {
|
||||
};
|
||||
|
||||
if let Some(err) = error {
|
||||
return Err(ShellError::SpannedLabeledErrorRelated(
|
||||
return Err(ShellError::GenericError(
|
||||
"error when parsing nuon text".into(),
|
||||
"could not parse nuon text".into(),
|
||||
head,
|
||||
Some(head),
|
||||
None,
|
||||
vec![ShellError::OutsideSpannedLabeledError(
|
||||
string_input,
|
||||
"error when parsing".into(),
|
||||
@ -174,10 +180,11 @@ impl Command for FromNuon {
|
||||
|
||||
match result {
|
||||
Ok(result) => Ok(result.into_pipeline_data()),
|
||||
Err(err) => Err(ShellError::SpannedLabeledErrorRelated(
|
||||
Err(err) => Err(ShellError::GenericError(
|
||||
"error when loading nuon text".into(),
|
||||
"could not load nuon text".into(),
|
||||
head,
|
||||
Some(head),
|
||||
None,
|
||||
vec![err],
|
||||
)),
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ pub fn convert_string_to_value(string_input: String, span: Span) -> Result<Value
|
||||
"structured toml data".into(),
|
||||
"string".into(),
|
||||
span,
|
||||
None,
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user