Improve error message

This commit is contained in:
Chris Tsang 2023-01-10 15:35:56 +08:00
parent 23ee592dae
commit ed7be8a29b

View File

@ -209,8 +209,13 @@ impl MockRow {
T: ValueType,
{
if let Some(index) = index.as_str() {
T::try_from(self.values.get(index).unwrap().clone())
.map_err(|e| DbErr::Type(e.to_string()))
T::try_from(
self.values
.get(index)
.unwrap_or_else(|| panic!("No column for ColIdx {:?}", index))
.clone(),
)
.map_err(|e| DbErr::Type(e.to_string()))
} else if let Some(index) = index.as_usize() {
let (_, value) = self.values.iter().nth(*index).ok_or_else(|| {
DbErr::Query(RuntimeErr::Internal(format!(