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

@ -140,18 +140,22 @@ pub fn icon_for_file(file_path: &Path, span: Span) -> Result<char, ShellError> {
let str = file_path
.file_name()
.ok_or_else(|| {
ShellError::SpannedLabeledError(
ShellError::GenericError(
"File name error".into(),
"Unable to get file name".into(),
span,
Some(span),
None,
Vec::new(),
)
})?
.to_str()
.ok_or_else(|| {
ShellError::SpannedLabeledError(
ShellError::GenericError(
"Unable to get str error".into(),
"Unable to convert to str file name".into(),
span,
Some(span),
None,
Vec::new(),
)
})?;
Ok(match str {
@ -164,10 +168,12 @@ pub fn icon_for_file(file_path: &Path, span: Span) -> Result<char, ShellError> {
Ok(icon)
} else if let Some(ext) = file_path.extension().as_ref() {
let str = ext.to_str().ok_or_else(|| {
ShellError::SpannedLabeledError(
ShellError::GenericError(
"Unable to get str error".into(),
"Unable to convert to str file name".into(),
span,
Some(span),
None,
Vec::new(),
)
})?;
Ok(match str {

View File

@ -417,9 +417,12 @@ fn convert_with_precision(val: &str, precision: usize) -> Result<String, ShellEr
let val_float = match val.trim().parse::<f64>() {
Ok(f) => f,
Err(e) => {
return Err(ShellError::LabeledError(
return Err(ShellError::GenericError(
format!("error converting string [{}] to f64", &val),
e.to_string(),
"".to_string(),
None,
Some(e.to_string()),
Vec::new(),
));
}
};