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-secure.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-secure.c')
-rw-r--r-- | src/interfaces/libpq/fe-secure.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 3df4a97f2e9..e74d3ccf69a 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -254,15 +254,13 @@ pqsecure_raw_read(PGconn *conn, void *ptr, size_t len) case EPIPE: case ECONNRESET: - 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."); break; default: - appendPQExpBuffer(&conn->errorMessage, - libpq_gettext("could not receive data from server: %s\n"), + libpq_append_conn_error(conn, "could not receive data from server: %s", SOCK_STRERROR(result_errno, sebuf, sizeof(sebuf))); break; @@ -420,7 +418,9 @@ retry_masked: snprintf(msgbuf, sizeof(msgbuf), libpq_gettext("server closed the connection unexpectedly\n" "\tThis probably means the server terminated abnormally\n" - "\tbefore or while processing the request.\n")); + "\tbefore or while processing the request.")); + /* keep newline out of translated string */ + strlcat(msgbuf, "\n", sizeof(msgbuf)); conn->write_err_msg = strdup(msgbuf); /* Now claim the write succeeded */ n = len; @@ -431,9 +431,11 @@ retry_masked: /* Store error message in conn->write_err_msg, if possible */ /* (strdup failure is OK, we'll cope later) */ snprintf(msgbuf, sizeof(msgbuf), - libpq_gettext("could not send data to server: %s\n"), + libpq_gettext("could not send data to server: %s"), SOCK_STRERROR(result_errno, sebuf, sizeof(sebuf))); + /* keep newline out of translated string */ + strlcat(msgbuf, "\n", sizeof(msgbuf)); conn->write_err_msg = strdup(msgbuf); /* Now claim the write succeeded */ n = len; |