1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-19 23:22:23 +03:00

Refactor/reword some error messages to avoid duplicates

Also, remove brackets around "EMPTY [ ARRAY ]".  An error message is
not the place to state that a keyword is optional.

Backpatch to 17.
This commit is contained in:
Alvaro Herrera
2024-08-07 11:30:36 -04:00
parent 22b4a1b561
commit 2bb969f399
5 changed files with 74 additions and 34 deletions

View File

@@ -4660,13 +4660,17 @@ ExecEvalJsonCoercionFinish(ExprState *state, ExprEvalStep *op)
if (DatumGetBool(jsestate->error.value))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("could not coerce ON ERROR expression (%s) to the RETURNING type",
/*- translator: first %s is a SQL/JSON clause (e.g. ON ERROR) */
errmsg("could not coerce %s expression (%s) to the RETURNING type",
"ON ERROR",
GetJsonBehaviorValueString(jsestate->jsexpr->on_error)),
errdetail("%s", jsestate->escontext.error_data->message)));
else if (DatumGetBool(jsestate->empty.value))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("could not coerce ON EMPTY expression (%s) to the RETURNING type",
/*- translator: first %s is a SQL/JSON clause (e.g. ON ERROR) */
errmsg("could not coerce %s expression (%s) to the RETURNING type",
"ON EMPTY",
GetJsonBehaviorValueString(jsestate->jsexpr->on_empty)),
errdetail("%s", jsestate->escontext.error_data->message)));