Fix confusing unnamed column and crash

This commit is contained in:
Jonathan Turner 2019-10-14 18:28:54 +13:00
parent 4eafb22d5b
commit a4a1588fbc
2 changed files with 14 additions and 6 deletions

View file

@ -60,11 +60,19 @@ pub fn get_column_path(
possible_matches.sort(); possible_matches.sort();
return Err(ShellError::labeled_error( if possible_matches.len() > 0 {
"Unknown column", return Err(ShellError::labeled_error(
format!("did you mean '{}'?", possible_matches[0].1), "Unknown column",
tag_for_tagged_list(path.iter().map(|p| p.tag())), format!("did you mean '{}'?", possible_matches[0].1),
)); tag_for_tagged_list(path.iter().map(|p| p.tag())),
));
} else {
return Err(ShellError::labeled_error(
"Unknown column",
"row does not contain this column",
tag_for_tagged_list(path.iter().map(|p| p.tag())),
));
}
} }
} }
} }

View file

@ -42,7 +42,7 @@ impl TableView {
let mut headers = TableView::merge_descriptors(values); let mut headers = TableView::merge_descriptors(values);
if headers.len() == 0 { if headers.len() == 0 {
headers.push("value".to_string()); headers.push("<unknown>".to_string());
} }
let mut entries = vec![]; let mut entries = vec![];