Re: Problems with Error Messages wrt Domains, Checks

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: john frazer <johnfrazer783(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problems with Error Messages wrt Domains, Checks
Date: 2018-03-19 16:32:53
Message-ID: CAKFQuwbhYv3kX5TrRQANCr7DLmVaNnEdEd=Ef=2nwfnqNRQ-Zw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 19, 2018 at 9:11 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> "David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> > On Mon, Mar 19, 2018 at 8:33 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >> But I wonder if we wouldn't be better off to put the regex into a
> >> detail line, ie
> >> errmsg("invalid regular expression: %s", ...),
> >> errdetail("Regular expression is \"%s\".", ...),
>
> > I'd consider at least supplying the first 30 or so characters (or maybe
> up
> > to the first newline, whichever is shorter) in the main message and then
> > the entire regex in the detail line.
>
> That seems like a lot more complication than this is worth, and it'd be
> confusing to users as well, if things are formatted differently for short
> and long regexes.
> ​
>

They would be formatted the same every time - just need to remember to add
the extra function call around the expression variable in the errmsg case.
Definitely not married to the idea though.

Saying "begins with" and then showing the entire regex shouldn't cause too
much confusion I'd hope.

> I thought
> about trying to discourage deviations by using common error-reporting
> subroutines, but there are enough legit differences in what needs to
> be done that that might not work well.
>

​Two support functions might suffice:​

present_regexp_for_errmsg(regex_var)
present_regexp_for_detailmsg(regex_var)

We can at least centralize how the expression itself is string-ified.

David J.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-03-19 16:47:52 Re: Error detail/hint style fixup
Previous Message Tom Lane 2018-03-19 16:11:21 Re: Problems with Error Messages wrt Domains, Checks