Re: Enhanced error message to include hint messages for redundant options error

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: Enhanced error message to include hint messages for redundant options error
Date: 2021-05-12 23:28:23
Message-ID: 20210512232823.GA32468@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

You can avoid duplicating the ereport like this:

+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("option \"%s\" specified more than once", defel->defname),
+ parser ? parser_errposition(pstate, defel->location) : 0));

... also, since e3a87b4991cc you can now elide the parens around the
auxiliary function calls:

+ ereport(ERROR,
+ errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("option \"%s\" specified more than once", defel->defname),
+ parser ? parser_errposition(pstate, defel->location) : 0));

Please do add a pg_attribute_noreturn() decorator. I'm not sure if any
compilers will complain about the code flow if you have that, but I
expect many (all?) will if you don't.

--
Álvaro Herrera Valdivia, Chile
"Java is clearly an example of money oriented programming" (A. Stepanov)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiro Ikeda 2021-05-13 00:05:37 Re: wal stats questions
Previous Message Alvaro Herrera 2021-05-12 23:19:27 Re: AlterSubscription_refresh "wrconn" wrong variable?