diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 5e1974be..05fe7688 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -190,8 +190,9 @@ pq_raise(connectionObject *conn, cursorObject *curs, PGresult **pgres) raise and a meaningful message is better than an empty one. Note: it can happen without it being our error: see ticket #82 */ if (err == NULL || err[0] == '\0') { - PyErr_SetString(DatabaseError, - "error with no message from the libpq"); + PyErr_Format(DatabaseError, + "error code %s with no error message from libpq", + PQresStatus(pgres == NULL ? PQstatus(conn->pgconn) : PQresultStatus(*pgres))); return; }