Error message refactoring

Take some untranslatable things out of the message and replace by
format placeholders, to reduce translatable strings and reduce
translation mistakes.
This commit is contained in:
Peter Eisentraut 2021-06-27 09:41:16 +02:00
parent dcffc9ba8a
commit c302a61390
3 changed files with 30 additions and 19 deletions

View File

@ -865,7 +865,8 @@ begin_prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn)
if (ctx->callbacks.begin_prepare_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication at prepare time requires begin_prepare_cb callback")));
errmsg("logical replication at prepare time requires a %s callback",
"begin_prepare_cb")));
/* do the actual work: call callback */
ctx->callbacks.begin_prepare_cb(ctx, txn);
@ -908,7 +909,8 @@ prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.prepare_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication at prepare time requires prepare_cb callback")));
errmsg("logical replication at prepare time requires a %s callback",
"prepare_cb")));
/* do the actual work: call callback */
ctx->callbacks.prepare_cb(ctx, txn, prepare_lsn);
@ -951,7 +953,8 @@ commit_prepared_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.commit_prepared_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication at prepare time requires commit_prepared_cb callback")));
errmsg("logical replication at prepare time requires a %s callback",
"commit_prepared_cb")));
/* do the actual work: call callback */
ctx->callbacks.commit_prepared_cb(ctx, txn, commit_lsn);
@ -995,7 +998,8 @@ rollback_prepared_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.rollback_prepared_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical replication at prepare time requires rollback_prepared_cb callback")));
errmsg("logical replication at prepare time requires a %s callback",
"rollback_prepared_cb")));
/* do the actual work: call callback */
ctx->callbacks.rollback_prepared_cb(ctx, txn, prepare_end_lsn,
@ -1217,7 +1221,8 @@ stream_start_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_start_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming requires a stream_start_cb callback")));
errmsg("logical streaming requires a %s callback",
"stream_start_cb")));
ctx->callbacks.stream_start_cb(ctx, txn);
@ -1263,7 +1268,8 @@ stream_stop_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_stop_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming requires a stream_stop_cb callback")));
errmsg("logical streaming requires a %s callback",
"stream_stop_cb")));
ctx->callbacks.stream_stop_cb(ctx, txn);
@ -1302,7 +1308,8 @@ stream_abort_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_abort_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming requires a stream_abort_cb callback")));
errmsg("logical streaming requires a %s callback",
"stream_abort_cb")));
ctx->callbacks.stream_abort_cb(ctx, txn, abort_lsn);
@ -1345,7 +1352,8 @@ stream_prepare_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_prepare_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming at prepare time requires a stream_prepare_cb callback")));
errmsg("logical streaming at prepare time requires a %s callback",
"stream_prepare_cb")));
ctx->callbacks.stream_prepare_cb(ctx, txn, prepare_lsn);
@ -1384,7 +1392,8 @@ stream_commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_commit_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming requires a stream_commit_cb callback")));
errmsg("logical streaming requires a %s callback",
"stream_commit_cb")));
ctx->callbacks.stream_commit_cb(ctx, txn, commit_lsn);
@ -1430,7 +1439,8 @@ stream_change_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
if (ctx->callbacks.stream_change_cb == NULL)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("logical streaming requires a stream_change_cb callback")));
errmsg("logical streaming requires a %s callback",
"stream_change_cb")));
ctx->callbacks.stream_change_cb(ctx, txn, relation, change);

View File

@ -2274,7 +2274,8 @@ serialize_expr_stats(AnlExprData *exprdata, int nexprs)
if (!OidIsValid(typOid))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"pg_statistic\" does not have a composite type")));
errmsg("relation \"%s\" does not have a composite type",
"pg_statistic")));
for (exprno = 0; exprno < nexprs; exprno++)
{

View File

@ -4182,11 +4182,11 @@ numeric_int4_opt_error(Numeric num, bool *have_error)
if (NUMERIC_IS_NAN(num))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert NaN to integer")));
errmsg("cannot convert NaN to %s", "integer")));
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert infinity to integer")));
errmsg("cannot convert infinity to %s", "integer")));
}
}
@ -4260,11 +4260,11 @@ numeric_int8(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert NaN to bigint")));
errmsg("cannot convert NaN to %s", "bigint")));
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert infinity to bigint")));
errmsg("cannot convert infinity to %s", "bigint")));
}
/* Convert to variable format and thence to int8 */
@ -4301,11 +4301,11 @@ numeric_int2(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert NaN to smallint")));
errmsg("cannot convert NaN to %s", "smallint")));
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert infinity to smallint")));
errmsg("cannot convert infinity to %s", "smallint")));
}
/* Convert to variable format and thence to int8 */
@ -4496,11 +4496,11 @@ numeric_pg_lsn(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert NaN to pg_lsn")));
errmsg("cannot convert NaN to %s", "pg_lsn")));
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot convert infinity to pg_lsn")));
errmsg("cannot convert infinity to %s", "pg_lsn")));
}
/* Convert to variable format and thence to pg_lsn */