mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-03 20:00:09 +03:00
Report libpq error code for errors with no message
Instead of: DatabaseError: error with no message from the libpq raise a message like: DatabaseError: error code PGRES_COPY_BOTH with no error message from libpq (In this particular case PGRES_COPY_BOTH isn't actually an error, but psycopg2 doesn't understand it and should treat it that way.) Fixes #352
This commit is contained in:
parent
4e92322d74
commit
82e4219260
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user