From 8ae9636422101f394a31fabc6ba4f53d9b2a6df8 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 11 Feb 2014 23:07:34 -0800 Subject: [PATCH] Forward errors from statement and portal cleanup --- src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7ae02142..d6373be7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -63,7 +63,6 @@ fn main() { #[warn(missing_doc)]; #[feature(macro_rules, struct_variant, globs, phase)]; -#[macro_escape]; extern mod collections; extern mod extra; @@ -1080,9 +1079,12 @@ impl<'conn> NormalPostgresStatement<'conn> { }, Sync])); loop { - // TODO forward db errors match if_ok_pg!(self.conn.read_message()) { ReadyForQuery { .. } => break, + ErrorResponse { fields } => { + if_ok!(self.conn.wait_for_ready()); + return Err(PgDbError(PostgresDbError::new(fields))); + } _ => {} } } @@ -1322,9 +1324,12 @@ impl<'stmt> PostgresResult<'stmt> { }, Sync])); loop { - // TODO forward PG errors match if_ok_pg!(self.stmt.conn.read_message()) { ReadyForQuery { .. } => break, + ErrorResponse { fields } => { + if_ok!(self.stmt.conn.wait_for_ready()); + return Err(PgDbError(PostgresDbError::new(fields))); + } _ => {} } }