From 28fd9e8bdb1b070a887eff757c8337a9b559ef3e Mon Sep 17 00:00:00 2001 From: Jim Radford Date: Mon, 31 Mar 2014 21:35:09 -0700 Subject: [PATCH] Better errors when a column has the wrong type --- src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 536bf1a9..b15f455e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,6 +91,7 @@ use std::io::net::tcp::TcpStream; use std::mem; use std::str; use std::task; +use std::fmt; use error::{DnsError, InvalidUrl, @@ -1359,7 +1360,7 @@ impl<'stmt> Container for PostgresRow<'stmt> { } } -impl<'stmt, I: RowIndex+Clone, T: FromSql> Index for PostgresRow<'stmt> { +impl<'stmt, I: RowIndex+Clone+fmt::Show, T: FromSql> Index for PostgresRow<'stmt> { /// Retreives the contents of a field of the row. /// /// A field can be accessed by the name or index of its column, though @@ -1384,7 +1385,7 @@ impl<'stmt, I: RowIndex+Clone, T: FromSql> Index for PostgresRow<'stmt> { fn index(&self, idx: &I) -> T { match self.get(idx.clone()) { Ok(ok) => ok, - Err(err) => fail!("error retrieving row: {}", err) + Err(err) => fail!("error retrieving row[{}]: {}", idx, err) } } }