@@ -1910,7 +1910,7 @@ json_object_agg_transfn(PG_FUNCTION_ARGS)
19101910if (val_type == InvalidOid || val_type == UNKNOWNOID )
19111911ereport (ERROR ,
19121912(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1913- errmsg ("arg 1: could not determine data type" )));
1913+ errmsg ("could not determine data type for argument %d" , 1 )));
19141914
19151915add_json (arg , false,state ,val_type , true);
19161916
@@ -1934,7 +1934,7 @@ json_object_agg_transfn(PG_FUNCTION_ARGS)
19341934if (val_type == InvalidOid || val_type == UNKNOWNOID )
19351935ereport (ERROR ,
19361936(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1937- errmsg ("arg 2: could not determine data type" )));
1937+ errmsg ("could not determine data type for argument %d" , 2 )));
19381938
19391939add_json (arg ,PG_ARGISNULL (2 ),state ,val_type , false);
19401940
@@ -1980,7 +1980,8 @@ json_build_object(PG_FUNCTION_ARGS)
19801980if (nargs %2 != 0 )
19811981ereport (ERROR ,
19821982(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1983- errmsg ("invalid number or arguments: object must be matched key value pairs" )));
1983+ errmsg ("invalid number or arguments" ),
1984+ errhint ("Object must be matched key value pairs." )));
19841985
19851986result = makeStringInfo ();
19861987
@@ -1994,7 +1995,8 @@ json_build_object(PG_FUNCTION_ARGS)
19941995if (PG_ARGISNULL (i ))
19951996ereport (ERROR ,
19961997(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
1997- errmsg ("arg %d: key cannot be null" ,i + 1 )));
1998+ errmsg ("argument %d cannot be null" ,i + 1 ),
1999+ errhint ("Object keys should be text." )));
19982000val_type = get_fn_expr_argtype (fcinfo -> flinfo ,i );
19992001
20002002/*
@@ -2016,7 +2018,8 @@ json_build_object(PG_FUNCTION_ARGS)
20162018if (val_type == InvalidOid || val_type == UNKNOWNOID )
20172019ereport (ERROR ,
20182020(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
2019- errmsg ("arg %d: could not determine data type" ,i + 1 )));
2021+ errmsg ("could not determine data type for argument %d" ,
2022+ i + 1 )));
20202023appendStringInfoString (result ,sep );
20212024sep = ", " ;
20222025add_json (arg , false,result ,val_type , true);
@@ -2042,7 +2045,8 @@ json_build_object(PG_FUNCTION_ARGS)
20422045if (val_type == InvalidOid || val_type == UNKNOWNOID )
20432046ereport (ERROR ,
20442047(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
2045- errmsg ("arg %d: could not determine data type" ,i + 2 )));
2048+ errmsg ("could not determine data type for argument %d" ,
2049+ i + 2 )));
20462050add_json (arg ,PG_ARGISNULL (i + 1 ),result ,val_type , false);
20472051
20482052}
@@ -2099,7 +2103,8 @@ json_build_array(PG_FUNCTION_ARGS)
20992103if (val_type == InvalidOid || val_type == UNKNOWNOID )
21002104ereport (ERROR ,
21012105(errcode (ERRCODE_INVALID_PARAMETER_VALUE ),
2102- errmsg ("arg %d: could not determine data type" ,i + 1 )));
2106+ errmsg ("could not determine data type for argument %d" ,
2107+ i + 1 )));
21032108appendStringInfoString (result ,sep );
21042109sep = ", " ;
21052110add_json (arg ,PG_ARGISNULL (i ),result ,val_type , false);