Re: improving user.c error messages

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: improving user.c error messages
Date: 2023-02-07 20:10:09
Message-ID: 20230207201009.GA450353@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 27, 2023 at 03:15:07PM -0800, Nathan Bossart wrote:
> One thing that feels a bit odd is how some of the DETAILs mention the
> operation being attempted while others do not. For example, we have
>
> ERROR: permission denied to drop role
> DETAIL: You must have SUPERUSER privilege to drop roles with SUPERUSER.
>
> In this case, the DETAIL explains the action that is prohibited. In other
> cases, we have something like
>
> ERROR: permission denied to alter role
> DETAIL: You must have CREATEROLE privilege and ADMIN OPTION on role "myrole".
>
> which does not. I think this is okay because adding "to alter the role" to
> the end of the DETAIL seems kind of awkward. But in other cases, such as
>
> ERROR: permission denied to use replication slots
> DETAIL: You must have REPLICATION privilege.
>
> adding the operation to the end seems less awkward (i.e., "You must have
> REPLICATION privilege to use replication slots."). I don't think there's
> any information lost by omitting the action in the DETAIL, so perhaps this
> is just a stylistic choice. I think I'm inclined to add the action to the
> DETAIL whenever it doesn't make the message lengthy and awkward, and leave
> it out otherwise. Thoughts?

Here is a new patch set with this change and some other light editing.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v5-0001-Improve-user.c-error-messages.patch text/x-diff 29.9 KB
v5-0002-Improve-more-insufficient-privileges-error-messag.patch text/x-diff 19.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sergei Kornilov 2023-02-07 20:14:52 Re:pg_stat_statements and "IN" conditions
Previous Message Andres Freund 2023-02-07 20:05:20 Re: Assertion failure in SnapBuildInitialSnapshot()