diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-10-16 15:28:16 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2013-10-16 17:50:10 +0100 |
commit | 1e623a951c88e3640849e44d73aeb384ef59fde7 (patch) | |
tree | d43c65f9aefc573694fd5603c5a771bbeeb8bd75 /psycopg/connection_int.c | |
parent | 345077d5f78900ec95691ff047499526a4aabfbe (diff) | |
download | psycopg2-1e623a951c88e3640849e44d73aeb384ef59fde7.tar.gz |
Meaningful connection errors report a meaningful message
Fixes issue #173.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r-- | psycopg/connection_int.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 7851b0a..5069e64 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -642,6 +642,7 @@ static int _conn_poll_connecting(connectionObject *self) { int res = PSYCO_POLL_ERROR; + const char *msg; Dprintf("conn_poll: poll connecting"); switch (PQconnectPoll(self->pgconn)) { @@ -656,7 +657,11 @@ _conn_poll_connecting(connectionObject *self) break; case PGRES_POLLING_FAILED: case PGRES_POLLING_ACTIVE: - PyErr_SetString(OperationalError, "asynchronous connection failed"); + msg = PQerrorMessage(self->pgconn); + if (!(msg && *msg)) { + msg = "asynchronous connection failed"; + } + PyErr_SetString(OperationalError, msg); res = PSYCO_POLL_ERROR; break; } |