Introduce an intermediary InvalidType error.

InvalidType is used where the column/parameter index is not known.
This commit is contained in:
gwenn
2016-05-30 20:35:56 +02:00
parent cabcaf3dcb
commit fb19e718cf
8 changed files with 55 additions and 43 deletions

View File

@@ -1066,7 +1066,10 @@ impl<'a, 'stmt> Row<'a, 'stmt> {
pub fn get_checked<I: RowIndex, T: FromSql>(&self, idx: I) -> Result<T> {
let idx = try!(idx.idx(self.stmt));
let value = unsafe { ValueRef::new(&self.stmt.stmt, idx) };
FromSql::column_result(value, idx)
FromSql::column_result(value).map_err(|err| match err {
Error::InvalidType(t) => Error::InvalidColumnType(idx, t),
_ => err,
})
}
/// Return the number of columns in the current row.