diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-11-15 11:50:04 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-11-15 12:16:50 +0100 |
commit | a9e9a9f32b35edf129c88e8b929ef223f8511f59 (patch) | |
tree | bf6081551ddd6dc77c66bc5dad0d6cf11d4a919c /src/interfaces/libpq/fe-misc.c | |
parent | 0873b2d354b9c73a69067c0afb92e35994adc47e (diff) | |
download | postgresql-a9e9a9f32b35edf129c88e8b929ef223f8511f59.tar.gz postgresql-a9e9a9f32b35edf129c88e8b929ef223f8511f59.zip |
libpq error message refactoring, part 2
This applies the new APIs to the code.
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/7c0232ef-7b44-68db-599d-b327d0640a77@enterprisedb.com
Diffstat (limited to 'src/interfaces/libpq/fe-misc.c')
-rw-r--r-- | src/interfaces/libpq/fe-misc.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index b040a2664ee..4159610f6c7 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -570,8 +570,7 @@ pqReadData(PGconn *conn) if (conn->sock == PGINVALID_SOCKET) { - appendPQExpBufferStr(&conn->errorMessage, - libpq_gettext("connection not open\n")); + libpq_append_conn_error(conn, "connection not open"); return -1; } @@ -749,10 +748,9 @@ retry4: * means the connection has been closed. Cope. */ definitelyEOF: - appendPQExpBufferStr(&conn->errorMessage, - libpq_gettext("server closed the connection unexpectedly\n" - "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + libpq_append_conn_error(conn, "server closed the connection unexpectedly\n" + "\tThis probably means the server terminated abnormally\n" + "\tbefore or while processing the request."); /* Come here if lower-level code already set a suitable errorMessage */ definitelyFailed: @@ -1002,8 +1000,7 @@ pqWaitTimed(int forRead, int forWrite, PGconn *conn, time_t finish_time) if (result == 0) { - appendPQExpBufferStr(&conn->errorMessage, - libpq_gettext("timeout expired\n")); + libpq_append_conn_error(conn, "timeout expired"); return 1; } @@ -1047,8 +1044,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time) return -1; if (conn->sock == PGINVALID_SOCKET) { - appendPQExpBufferStr(&conn->errorMessage, - libpq_gettext("invalid socket\n")); + libpq_append_conn_error(conn, "invalid socket"); return -1; } @@ -1070,9 +1066,7 @@ pqSocketCheck(PGconn *conn, int forRead, int forWrite, time_t end_time) { char sebuf[PG_STRERROR_R_BUFLEN]; - appendPQExpBuffer(&conn->errorMessage, - libpq_gettext("%s() failed: %s\n"), - "select", + libpq_append_conn_error(conn, "%s() failed: %s", "select", SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf))); } |