From ed7be8a29bdd6187047fb9c4b857fd78a7341f37 Mon Sep 17 00:00:00 2001 From: Chris Tsang Date: Tue, 10 Jan 2023 15:35:56 +0800 Subject: [PATCH] Improve error message --- src/database/mock.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/database/mock.rs b/src/database/mock.rs index b12717eb5..ed52b4907 100644 --- a/src/database/mock.rs +++ b/src/database/mock.rs @@ -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!(