Skip to content

Commit 28fd9e8

Browse files
committed
Better errors when a column has the wrong type
1 parent a9ec725 commit 28fd9e8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ use std::io::net::tcp::TcpStream;
9191
use std::mem;
9292
use std::str;
9393
use std::task;
94+
use std::fmt;
9495

9596
use error::{DnsError,
9697
InvalidUrl,
@@ -1359,7 +1360,7 @@ impl<'stmt> Container for PostgresRow<'stmt> {
13591360
}
13601361
}
13611362

1362-
impl<'stmt, I: RowIndex+Clone, T: FromSql> Index<I, T> for PostgresRow<'stmt> {
1363+
impl<'stmt, I: RowIndex+Clone+fmt::Show, T: FromSql> Index<I, T> for PostgresRow<'stmt> {
13631364
/// Retreives the contents of a field of the row.
13641365
///
13651366
/// 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<I, T> for PostgresRow<'stmt> {
13841385
fn index(&self, idx: &I) -> T {
13851386
match self.get(idx.clone()) {
13861387
Ok(ok) => ok,
1387-
Err(err) => fail!("error retrieving row: {}", err)
1388+
Err(err) => fail!("error retrieving row[{}]: {}", idx, err)
13881389
}
13891390
}
13901391
}

0 commit comments

Comments
 (0)