update miette and switch to GenericErrors (#5222)

This commit is contained in:
Kat Marchán
2022-04-18 05:34:10 -07:00
committed by GitHub
parent cf65f77b02
commit 1314a87cb0
141 changed files with 1569 additions and 689 deletions

View File

@ -383,10 +383,12 @@ Format: #
None => Color::White.prefix().to_string(),
},
Err(err) => {
return Err(ShellError::SpannedLabeledError(
return Err(ShellError::GenericError(
"error parsing hex color".to_string(),
format!("{}", err),
code.span()?,
Some(code.span()?),
None,
Vec::new(),
));
}
}

View File

@ -95,7 +95,13 @@ impl Command for Du {
let exclude = args.exclude.map_or(Ok(None), move |x| {
Pattern::new(&x.item).map(Some).map_err(|e| {
ShellError::SpannedLabeledError(e.msg.to_string(), "glob error".to_string(), x.span)
ShellError::GenericError(
e.msg.to_string(),
"glob error".to_string(),
Some(x.span),
None,
Vec::new(),
)
})
})?;
@ -108,7 +114,13 @@ impl Command for Du {
None => nu_glob::glob_with("*", GLOB_PARAMS),
}
.map_err(|e| {
ShellError::SpannedLabeledError(e.msg.to_string(), "glob error".to_string(), tag)
ShellError::GenericError(
e.msg.to_string(),
"glob error".to_string(),
Some(tag),
None,
Vec::new(),
)
})?
.filter(move |p| {
if include_files {

View File

@ -87,10 +87,12 @@ impl Command for Kill {
left_span: call
.get_named_arg("force")
.ok_or_else(|| {
ShellError::SpannedLabeledError(
ShellError::GenericError(
"Flag error".into(),
"flag force not found".into(),
call.head,
Some(call.head),
None,
Vec::new(),
)
})?
.span,
@ -98,10 +100,12 @@ impl Command for Kill {
right_span: span(&[
call.get_named_arg("signal")
.ok_or_else(|| {
ShellError::SpannedLabeledError(
ShellError::GenericError(
"Flag error".into(),
"flag signal not found".into(),
call.head,
Some(call.head),
None,
Vec::new(),
)
})?
.span,

View File

@ -36,9 +36,12 @@ impl Command for KeybindingsListen {
Ok(v) => Ok(v.into_pipeline_data()),
Err(e) => {
terminal::disable_raw_mode()?;
Err(ShellError::LabeledError(
Err(ShellError::GenericError(
"Error with input".to_string(),
e.to_string(),
"".to_string(),
None,
Some(e.to_string()),
Vec::new(),
))
}
}