Re: Enhanced error message to include hint messages for redundant options error - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Enhanced error message to include hint messages for redundant options error
Date
Msg-id 20210512232823.GA32468@alvherre.pgsql
Whole thread Raw
In response to Re: Enhanced error message to include hint messages for redundant options error  (vignesh C <vignesh21@gmail.com>)
Responses Re: Enhanced error message to include hint messages for redundant options error  (vignesh C <vignesh21@gmail.com>)
List 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)



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: AlterSubscription_refresh "wrconn" wrong variable?
Next
From: Masahiro Ikeda
Date:
Subject: Re: wal stats questions