Re: Internationalized error messages - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Internationalized error messages
Date
Msg-id Pine.LNX.4.30.0103091643350.929-100000@peter.localdomain
Whole thread Raw
In response to Re: Internationalized error messages  (ncm@zembu.com (Nathan Myers))
List pgsql-hackers
Nathan Myers writes:

> >     elog(ERROR, "XYZ01", gettext("stuff happened"));
>
> Similar approaches have been tried frequently, and even enshrined
> in standards (e.g. POSIX catgets), but have almost always proven too
> cumbersome.  The problem is that keeping programs that interpret the
> numeric code in sync with the program they monitor is hard, and trying
> to avoid breaking all those secondary programs hinders development on
> the primary program.

That's why no one uses catgets and everyone uses gettext.

> Furthermore, assigning code numbers is a nuisance, and they add
> uninformative clutter.

The error codes are exactly what we want, to allow client programs (as
opposed to humans) to identify the errors.  The code in my example has
nothing to do with the message id in the catgets interface.

> It's better to scan the program for elog() arguments, and generate
> a catalog by using the string itself as the index code.  Those
> maintaining the secondary programs can compare catalogs to see what
> has been broken by changes and what new messages to expect.  elog()
> itself can (optionally) invent tokens (e.g. catalog indices) to help
> out those programs.

That's what gettext does for you.

-- 
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: AW: WAL does not recover gracefully from out-of-disk-sp ace
Next
From: Peter Eisentraut
Date:
Subject: Re: Internationalized error messages