2010-09-20 22:08:53 +02:00
|
|
|
<!-- doc/src/sgml/sources.sgml -->
|
2000-03-31 05:27:42 +02:00
|
|
|
|
2000-09-29 22:21:34 +02:00
|
|
|
<chapter id="source">
|
2003-06-22 18:17:01 +02:00
|
|
|
<title>PostgreSQL Coding Conventions</title>
|
2000-02-02 17:25:04 +01:00
|
|
|
|
2000-09-29 22:21:34 +02:00
|
|
|
<sect1 id="source-format">
|
2000-02-02 17:25:04 +01:00
|
|
|
<title>Formatting</title>
|
|
|
|
|
|
|
|
<para>
|
2008-09-07 04:01:04 +02:00
|
|
|
Source code formatting uses 4 column tab spacing, with
|
|
|
|
tabs preserved (i.e., tabs are not expanded to spaces).
|
2003-05-19 23:38:24 +02:00
|
|
|
Each logical indentation level is one additional tab stop.
|
2008-09-07 04:01:04 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Layout rules (brace positioning, etc) follow BSD conventions. In
|
|
|
|
particular, curly braces for the controlled blocks of <literal>if</>,
|
|
|
|
<literal>while</>, <literal>switch</>, etc go on their own lines.
|
|
|
|
</para>
|
|
|
|
|
2010-07-10 20:37:00 +02:00
|
|
|
<para>
|
|
|
|
Limit line lengths so that the code is readable in an 80-column window.
|
|
|
|
(This doesn't mean that you must never go past 80 columns. For instance,
|
|
|
|
breaking a long error message string in arbitrary places just to keep the
|
|
|
|
code within 80 columns is probably not a net gain in readability.)
|
|
|
|
</para>
|
|
|
|
|
2008-09-07 04:01:04 +02:00
|
|
|
<para>
|
|
|
|
Do not use C++ style comments (<literal>//</> comments). Strict ANSI C
|
|
|
|
compilers do not accept them. For the same reason, do not use C++
|
|
|
|
extensions such as declaring new variables mid-block.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The preferred style for multi-line comment blocks is
|
|
|
|
<programlisting>
|
|
|
|
/*
|
|
|
|
* comment text begins here
|
|
|
|
* and continues here
|
|
|
|
*/
|
|
|
|
</programlisting>
|
|
|
|
Note that comment blocks that begin in column 1 will be preserved as-is
|
|
|
|
by <application>pgindent</>, but it will re-flow indented comment blocks
|
|
|
|
as though they were plain text. If you want to preserve the line breaks
|
|
|
|
in an indented block, add dashes like this:
|
|
|
|
<programlisting>
|
|
|
|
/*----------
|
|
|
|
* comment text begins here
|
|
|
|
* and continues here
|
|
|
|
*----------
|
|
|
|
*/
|
|
|
|
</programlisting>
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
While submitted patches do not absolutely have to follow these formatting
|
|
|
|
rules, it's a good idea to do so. Your code will get run through
|
2008-09-07 04:01:04 +02:00
|
|
|
<application>pgindent</> before the next release, so there's no point in
|
|
|
|
making it look nice under some other set of formatting conventions.
|
2010-07-10 20:37:00 +02:00
|
|
|
A good rule of thumb for patches is <quote>make the new code look like
|
|
|
|
the existing code around it</>.
|
2000-02-02 17:25:04 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2008-09-07 04:01:04 +02:00
|
|
|
The <filename>src/tools</filename> directory contains sample settings
|
|
|
|
files that can be used with the <productname>emacs</productname>,
|
|
|
|
<productname>xemacs</productname> or <productname>vim</productname>
|
|
|
|
editors to help ensure that they format code according to these
|
2007-02-01 23:06:14 +01:00
|
|
|
conventions.
|
2000-02-02 17:25:04 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The text browsing tools <application>more</application> and
|
2007-02-01 01:28:19 +01:00
|
|
|
<application>less</application> can be invoked as:
|
2001-10-09 20:46:00 +02:00
|
|
|
<programlisting>
|
2000-02-02 17:25:04 +01:00
|
|
|
more -x4
|
|
|
|
less -x4
|
2001-10-09 20:46:00 +02:00
|
|
|
</programlisting>
|
2003-05-19 23:38:24 +02:00
|
|
|
to make them show tabs appropriately.
|
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
<sect1 id="error-message-reporting">
|
|
|
|
<title>Reporting Errors Within the Server</title>
|
|
|
|
|
2003-06-22 18:17:01 +02:00
|
|
|
<indexterm>
|
|
|
|
<primary>ereport</primary>
|
|
|
|
</indexterm>
|
|
|
|
<indexterm>
|
|
|
|
<primary>elog</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2003-05-19 23:38:24 +02:00
|
|
|
<para>
|
|
|
|
Error, warning, and log messages generated within the server code
|
|
|
|
should be created using <function>ereport</>, or its older cousin
|
|
|
|
<function>elog</>. The use of this function is complex enough to
|
|
|
|
require some explanation.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
There are two required elements for every message: a severity level
|
|
|
|
(ranging from <literal>DEBUG</> to <literal>PANIC</>) and a primary
|
|
|
|
message text. In addition there are optional elements, the most
|
|
|
|
common of which is an error identifier code that follows the SQL spec's
|
|
|
|
SQLSTATE conventions.
|
|
|
|
<function>ereport</> itself is just a shell function, that exists
|
|
|
|
mainly for the syntactic convenience of making message generation
|
|
|
|
look like a function call in the C source code. The only parameter
|
|
|
|
accepted directly by <function>ereport</> is the severity level.
|
|
|
|
The primary message text and any optional message elements are
|
|
|
|
generated by calling auxiliary functions, such as <function>errmsg</>,
|
|
|
|
within the <function>ereport</> call.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
A typical call to <function>ereport</> might look like this:
|
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_DIVISION_BY_ZERO),
|
|
|
|
errmsg("division by zero")));
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
This specifies error severity level <literal>ERROR</> (a run-of-the-mill
|
|
|
|
error). The <function>errcode</> call specifies the SQLSTATE error code
|
2003-07-27 20:37:52 +02:00
|
|
|
using a macro defined in <filename>src/include/utils/errcodes.h</>. The
|
2003-05-19 23:38:24 +02:00
|
|
|
<function>errmsg</> call provides the primary message text. Notice the
|
2004-11-15 07:32:15 +01:00
|
|
|
extra set of parentheses surrounding the auxiliary function calls —
|
2003-05-19 23:38:24 +02:00
|
|
|
these are annoying but syntactically necessary.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Here is a more complex example:
|
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
ereport(ERROR,
|
|
|
|
(errcode(ERRCODE_AMBIGUOUS_FUNCTION),
|
|
|
|
errmsg("function %s is not unique",
|
|
|
|
func_signature_string(funcname, nargs,
|
2009-10-08 04:39:25 +02:00
|
|
|
NIL, actual_arg_types)),
|
2004-12-13 19:05:10 +01:00
|
|
|
errhint("Unable to choose a best candidate function. "
|
Wording cleanup for error messages. Also change can't -> cannot.
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 20:10:30 +01:00
|
|
|
"You might need to add explicit typecasts.")));
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
This illustrates the use of format codes to embed run-time values into
|
|
|
|
a message text. Also, an optional <quote>hint</> message is provided.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The available auxiliary routines for <function>ereport</> are:
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errcode(sqlerrcode)</function> specifies the SQLSTATE error identifier
|
2003-07-19 01:20:33 +02:00
|
|
|
code for the condition. If this routine is not called, the error
|
|
|
|
identifier defaults to
|
2003-07-27 20:37:52 +02:00
|
|
|
<literal>ERRCODE_INTERNAL_ERROR</> when the error severity level is
|
2003-07-19 01:20:33 +02:00
|
|
|
<literal>ERROR</> or higher, <literal>ERRCODE_WARNING</> when the
|
|
|
|
error level is <literal>WARNING</>, otherwise (for <literal>NOTICE</>
|
|
|
|
and below) <literal>ERRCODE_SUCCESSFUL_COMPLETION</>.
|
|
|
|
While these defaults are often convenient, always think whether they
|
2004-12-13 19:05:10 +01:00
|
|
|
are appropriate before omitting the <function>errcode()</> call.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errmsg(const char *msg, ...)</function> specifies the primary error
|
2003-05-19 23:38:24 +02:00
|
|
|
message text, and possibly run-time values to insert into it. Insertions
|
|
|
|
are specified by <function>sprintf</>-style format codes. In addition to
|
|
|
|
the standard format codes accepted by <function>sprintf</>, the format
|
|
|
|
code <literal>%m</> can be used to insert the error message returned
|
|
|
|
by <function>strerror</> for the current value of <literal>errno</>.
|
|
|
|
<footnote>
|
|
|
|
<para>
|
|
|
|
That is, the value that was current when the <function>ereport</> call
|
|
|
|
was reached; changes of <literal>errno</> within the auxiliary reporting
|
|
|
|
routines will not affect it. That would not be true if you were to
|
|
|
|
write <literal>strerror(errno)</> explicitly in <function>errmsg</>'s
|
|
|
|
parameter list; accordingly, do not do so.
|
|
|
|
</para>
|
|
|
|
</footnote>
|
|
|
|
<literal>%m</> does not require any
|
|
|
|
corresponding entry in the parameter list for <function>errmsg</>.
|
|
|
|
Note that the message string will be run through <function>gettext</>
|
|
|
|
for possible localization before format codes are processed.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errmsg_internal(const char *msg, ...)</function> is the same as
|
2003-05-19 23:38:24 +02:00
|
|
|
<function>errmsg</>, except that the message string will not be
|
2008-10-27 20:37:22 +01:00
|
|
|
translated nor included in the internationalization message dictionary.
|
Wording cleanup for error messages. Also change can't -> cannot.
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 20:10:30 +01:00
|
|
|
This should be used for <quote>cannot happen</> cases that are probably
|
2003-05-19 23:38:24 +02:00
|
|
|
not worth expending translation effort on.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2009-06-04 20:33:08 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errmsg_plural(const char *fmt_singular, const char *fmt_plural,
|
|
|
|
unsigned long n, ...)</function> is like <function>errmsg</>, but with
|
|
|
|
support for various plural forms of the message.
|
|
|
|
<replaceable>fmt_singular</> is the English singular format,
|
|
|
|
<replaceable>fmt_plural</> is the English plural format,
|
|
|
|
<replaceable>n</> is the integer value that determines which plural
|
|
|
|
form is needed, and the remaining arguments are formatted according
|
|
|
|
to the selected format string. For more information see
|
|
|
|
<xref linkend="nls-guidelines">.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2003-05-19 23:38:24 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errdetail(const char *msg, ...)</function> supplies an optional
|
2003-05-19 23:38:24 +02:00
|
|
|
<quote>detail</> message; this is to be used when there is additional
|
|
|
|
information that seems inappropriate to put in the primary message.
|
|
|
|
The message string is processed in just the same way as for
|
|
|
|
<function>errmsg</>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2008-03-24 19:08:47 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2011-07-16 19:41:48 +02:00
|
|
|
<function>errdetail_internal(const char *msg, ...)</function> is the same
|
|
|
|
as <function>errdetail</>, except that the message string will not be
|
|
|
|
translated nor included in the internationalization message dictionary.
|
|
|
|
This should be used for detail messages that are not worth expending
|
|
|
|
translation effort on, for instance because they are too technical to be
|
|
|
|
useful to most users.
|
2008-03-24 19:08:47 +01:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2009-06-04 20:33:08 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
|
|
|
unsigned long n, ...)</function> is like <function>errdetail</>, but with
|
|
|
|
support for various plural forms of the message.
|
|
|
|
For more information see <xref linkend="nls-guidelines">.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2011-07-16 19:41:48 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errdetail_log(const char *msg, ...)</function> is the same as
|
|
|
|
<function>errdetail</> except that this string goes only to the server
|
|
|
|
log, never to the client. If both <function>errdetail</> (or one of
|
|
|
|
its equivalents above) and
|
|
|
|
<function>errdetail_log</> are used then one string goes to the client
|
|
|
|
and the other to the log. This is useful for error details that are
|
|
|
|
too security-sensitive or too bulky to include in the report
|
|
|
|
sent to the client.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2003-05-19 23:38:24 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errhint(const char *msg, ...)</function> supplies an optional
|
2003-05-19 23:38:24 +02:00
|
|
|
<quote>hint</> message; this is to be used when offering suggestions
|
|
|
|
about how to fix the problem, as opposed to factual details about
|
|
|
|
what went wrong.
|
|
|
|
The message string is processed in just the same way as for
|
|
|
|
<function>errmsg</>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errcontext(const char *msg, ...)</function> is not normally called
|
2003-05-19 23:38:24 +02:00
|
|
|
directly from an <function>ereport</> message site; rather it is used
|
|
|
|
in <literal>error_context_stack</> callback functions to provide
|
|
|
|
information about the context in which an error occurred, such as the
|
|
|
|
current location in a PL function.
|
|
|
|
The message string is processed in just the same way as for
|
|
|
|
<function>errmsg</>. Unlike the other auxiliary functions, this can
|
|
|
|
be called more than once per <function>ereport</> call; the successive
|
|
|
|
strings thus supplied are concatenated with separating newlines.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errposition(int cursorpos)</function> specifies the textual location
|
2003-05-19 23:38:24 +02:00
|
|
|
of an error within a query string. Currently it is only useful for
|
|
|
|
errors detected in the lexical and syntactic analysis phases of
|
|
|
|
query processing.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure. It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error. (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)
Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.
Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.
2013-01-29 23:06:26 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errtable(Relation rel)</function> specifies a relation whose
|
|
|
|
name and schema name should be included as auxiliary fields in the error
|
|
|
|
report.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errtablecol(Relation rel, int attnum)</function> specifies
|
|
|
|
a column whose name, table name, and schema name should be included as
|
|
|
|
auxiliary fields in the error report.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errtableconstraint(Relation rel, const char *conname)</function>
|
|
|
|
specifies a table constraint whose name, table name, and schema name
|
|
|
|
should be included as auxiliary fields in the error report. Indexes
|
|
|
|
should be considered to be constraints for this purpose, whether or
|
|
|
|
not they have an associated <structname>pg_constraint</> entry. Be
|
|
|
|
careful to pass the underlying heap relation, not the index itself, as
|
|
|
|
<literal>rel</>.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errdatatype(Oid datatypeOid)</function> specifies a data
|
|
|
|
type whose name and schema name should be included as auxiliary fields
|
|
|
|
in the error report.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errdomainconstraint(Oid datatypeOid, const char *conname)</function>
|
|
|
|
specifies a domain constraint whose name, domain name, and schema name
|
|
|
|
should be included as auxiliary fields in the error report.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2003-07-19 01:20:33 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errcode_for_file_access()</> is a convenience function that
|
2003-07-19 01:20:33 +02:00
|
|
|
selects an appropriate SQLSTATE error identifier for a failure in a
|
|
|
|
file-access-related system call. It uses the saved
|
|
|
|
<literal>errno</> to determine which error code to generate.
|
|
|
|
Usually this should be used in combination with <literal>%m</> in the
|
|
|
|
primary error message text.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2003-07-22 21:00:12 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2004-12-13 19:05:10 +01:00
|
|
|
<function>errcode_for_socket_access()</> is a convenience function that
|
2003-07-22 21:00:12 +02:00
|
|
|
selects an appropriate SQLSTATE error identifier for a failure in a
|
|
|
|
socket-related system call.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2007-03-03 00:37:23 +01:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
<function>errhidestmt(bool hide_stmt)</function> can be called to specify
|
|
|
|
suppression of the <literal>STATEMENT:</> portion of a message in the
|
|
|
|
postmaster log. Generally this is appropriate if the message text
|
|
|
|
includes the current statement already.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2003-05-19 23:38:24 +02:00
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
Provide database object names as separate fields in error messages.
This patch addresses the problem that applications currently have to
extract object names from possibly-localized textual error messages,
if they want to know for example which index caused a UNIQUE_VIOLATION
failure. It adds new error message fields to the wire protocol, which
can carry the name of a table, table column, data type, or constraint
associated with the error. (Since the protocol spec has always instructed
clients to ignore unrecognized field types, this should not create any
compatibility problem.)
Support for providing these new fields has been added to just a limited set
of error reports (mainly, those in the "integrity constraint violation"
SQLSTATE class), but we will doubtless add them to more calls in future.
Pavel Stehule, reviewed and extensively revised by Peter Geoghegan, with
additional hacking by Tom Lane.
2013-01-29 23:06:26 +01:00
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
At most one of the functions <function>errtable</>,
|
|
|
|
<function>errtablecol</>, <function>errtableconstraint</>,
|
|
|
|
<function>errdatatype</>, or <function>errdomainconstraint</> should
|
|
|
|
be used in an <function>ereport</> call. These functions exist to
|
|
|
|
allow applications to extract the name of a database object associated
|
|
|
|
with the error condition without having to examine the
|
|
|
|
potentially-localized error message text.
|
|
|
|
These functions should be used in error reports for which it's likely
|
|
|
|
that applications would wish to have automatic error handling. As of
|
|
|
|
<productname>PostgreSQL</> 9.3, complete coverage exists only for
|
|
|
|
errors in SQLSTATE class 23 (integrity constraint violation), but this
|
|
|
|
is likely to be expanded in future.
|
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
|
2003-05-19 23:38:24 +02:00
|
|
|
<para>
|
2003-07-27 20:37:52 +02:00
|
|
|
There is an older function <function>elog</> that is still heavily used.
|
2007-02-01 01:28:19 +01:00
|
|
|
An <function>elog</> call:
|
2003-07-27 20:37:52 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
elog(level, "format string", ...);
|
2003-07-27 20:37:52 +02:00
|
|
|
</programlisting>
|
2007-02-01 01:28:19 +01:00
|
|
|
is exactly equivalent to:
|
2003-07-27 20:37:52 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
ereport(level, (errmsg_internal("format string", ...)));
|
2003-07-27 20:37:52 +02:00
|
|
|
</programlisting>
|
2006-10-23 20:10:32 +02:00
|
|
|
Notice that the SQLSTATE error code is always defaulted, and the message
|
2008-10-27 20:37:22 +01:00
|
|
|
string is not subject to translation.
|
2003-07-27 20:37:52 +02:00
|
|
|
Therefore, <function>elog</> should be used only for internal errors and
|
|
|
|
low-level debug logging. Any message that is likely to be of interest to
|
|
|
|
ordinary users should go through <function>ereport</>. Nonetheless,
|
Wording cleanup for error messages. Also change can't -> cannot.
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 20:10:30 +01:00
|
|
|
there are enough internal <quote>cannot happen</> error checks in the
|
2003-07-27 20:37:52 +02:00
|
|
|
system that <function>elog</> is still widely used; it is preferred for
|
|
|
|
those messages for its notational simplicity.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Advice about writing good error messages can be found in
|
|
|
|
<xref linkend="error-style-guide">.
|
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
<sect1 id="error-style-guide">
|
|
|
|
<title>Error Message Style Guide</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
This style guide is offered in the hope of maintaining a consistent,
|
|
|
|
user-friendly style throughout all the messages generated by
|
|
|
|
<productname>PostgreSQL</>.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>What Goes Where</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
The primary message should be short, factual, and avoid reference to
|
|
|
|
implementation details such as specific function names.
|
|
|
|
<quote>Short</quote> means <quote>should fit on one line under normal
|
|
|
|
conditions</quote>. Use a detail message if needed to keep the primary
|
|
|
|
message short, or if you feel a need to mention implementation details
|
|
|
|
such as the particular system call that failed. Both primary and detail
|
|
|
|
messages should be factual. Use a hint message for suggestions about what
|
|
|
|
to do to fix the problem, especially if the suggestion might not always be
|
|
|
|
applicable.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2007-02-01 01:28:19 +01:00
|
|
|
For example, instead of:
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %m
|
|
|
|
(plus a long addendum that is basically a hint)
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
2007-02-01 01:28:19 +01:00
|
|
|
write:
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
Primary: could not create shared memory segment: %m
|
|
|
|
Detail: Failed syscall was shmget(key=%d, size=%u, 0%o).
|
|
|
|
Hint: the addendum
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: keeping the primary message short helps keep it to the point,
|
|
|
|
and lets clients lay out screen space on the assumption that one line is
|
Update documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
Also update two error messages mentioned in the documenation to match.
2007-01-31 21:56:20 +01:00
|
|
|
enough for error messages. Detail and hint messages can be relegated to a
|
2003-05-19 23:38:24 +02:00
|
|
|
verbose mode, or perhaps a pop-up error-details window. Also, details and
|
|
|
|
hints would normally be suppressed from the server log to save
|
|
|
|
space. Reference to implementation details is best avoided since users
|
|
|
|
don't know the details anyway.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
|
|
|
<title>Formatting</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Don't put any specific assumptions about formatting into the message
|
|
|
|
texts. Expect clients and the server log to wrap lines to fit their own
|
Update documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
Also update two error messages mentioned in the documenation to match.
2007-01-31 21:56:20 +01:00
|
|
|
needs. In long messages, newline characters (\n) can be used to indicate
|
2003-05-19 23:38:24 +02:00
|
|
|
suggested paragraph breaks. Don't end a message with a newline. Don't
|
|
|
|
use tabs or other formatting characters. (In error context displays,
|
|
|
|
newlines are automatically added to separate levels of context such as
|
|
|
|
function calls.)
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: Messages are not necessarily displayed on terminal-type
|
|
|
|
displays. In GUI displays or browsers these formatting instructions are
|
|
|
|
at best ignored.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Quotation Marks</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
English text should use double quotes when quoting is appropriate.
|
|
|
|
Text in other languages should consistently use one kind of quotes that is
|
|
|
|
consistent with publishing customs and computer output of other programs.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: The choice of double quotes over single quotes is somewhat
|
|
|
|
arbitrary, but tends to be the preferred use. Some have suggested
|
|
|
|
choosing the kind of quotes depending on the type of object according to
|
|
|
|
SQL conventions (namely, strings single quoted, identifiers double
|
|
|
|
quoted). But this is a language-internal technical issue that many users
|
|
|
|
aren't even familiar with, it won't scale to other kinds of quoted terms,
|
|
|
|
it doesn't translate to other languages, and it's pretty pointless, too.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Use of Quotes</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Use quotes always to delimit file names, user-supplied identifiers, and
|
|
|
|
other variables that might contain words. Do not use them to mark up
|
|
|
|
variables that will not contain words (for example, operator names).
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
There are functions in the backend that will double-quote their own output
|
2010-09-09 02:48:22 +02:00
|
|
|
at need (for example, <function>format_type_be()</function>). Do not put
|
2009-06-04 20:33:08 +02:00
|
|
|
additional quotes around the output of such functions.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: Objects can have names that create ambiguity when embedded in a
|
|
|
|
message. Be consistent about denoting where a plugged-in name starts and
|
|
|
|
ends. But don't clutter messages with unnecessary or duplicate quote
|
2009-06-04 20:33:08 +02:00
|
|
|
marks.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Grammar and Punctuation</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
The rules are different for primary error messages and for detail/hint
|
|
|
|
messages:
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Primary error messages: Do not capitalize the first letter. Do not end a
|
|
|
|
message with a period. Do not even think about ending a message with an
|
2009-06-04 20:33:08 +02:00
|
|
|
exclamation point.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Detail and hint messages: Use complete sentences, and end each with
|
2007-11-07 14:12:21 +01:00
|
|
|
a period. Capitalize the first word of sentences. Put two spaces after
|
|
|
|
the period if another sentence follows (for English text; might be
|
|
|
|
inappropriate in other languages).
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
2010-06-28 19:48:26 +02:00
|
|
|
<para>
|
|
|
|
Error context strings: Do not capitalize the first letter and do
|
|
|
|
not end the string with a period. Context strings should normally
|
|
|
|
not be complete sentences.
|
|
|
|
</para>
|
|
|
|
|
2003-05-19 23:38:24 +02:00
|
|
|
<para>
|
|
|
|
Rationale: Avoiding punctuation makes it easier for client applications to
|
|
|
|
embed the message into a variety of grammatical contexts. Often, primary
|
|
|
|
messages are not grammatically complete sentences anyway. (And if they're
|
|
|
|
long enough to be more than one sentence, they should be split into
|
|
|
|
primary and detail parts.) However, detail and hint messages are longer
|
Update documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
Also update two error messages mentioned in the documenation to match.
2007-01-31 21:56:20 +01:00
|
|
|
and might need to include multiple sentences. For consistency, they should
|
2009-06-04 20:33:08 +02:00
|
|
|
follow complete-sentence style even when there's only one sentence.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Upper Case vs. Lower Case</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Use lower case for message wording, including the first letter of a
|
|
|
|
primary error message. Use upper case for SQL commands and key words if
|
2004-02-17 03:53:03 +01:00
|
|
|
they appear in the message.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: It's easier to make everything look more consistent this
|
|
|
|
way, since some messages are complete sentences and some not.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Avoid Passive Voice</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Use the active voice. Use complete sentences when there is an acting
|
|
|
|
subject (<quote>A could not do B</quote>). Use telegram style without
|
|
|
|
subject if the subject would be the program itself; do not use
|
|
|
|
<quote>I</quote> for the program.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: The program is not human. Don't pretend otherwise.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Present vs. Past Tense</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Use past tense if an attempt to do something failed, but could perhaps
|
|
|
|
succeed next time (perhaps after fixing some problem). Use present tense
|
2009-06-04 20:33:08 +02:00
|
|
|
if the failure is certainly permanent.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2007-02-01 01:28:19 +01:00
|
|
|
There is a nontrivial semantic difference between sentences of the form:
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
could not open file "%s": %m
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
2007-02-01 01:28:19 +01:00
|
|
|
and:
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
cannot open file "%s"
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
The first one means that the attempt to open the file failed. The
|
|
|
|
message should give a reason, such as <quote>disk full</quote> or
|
|
|
|
<quote>file doesn't exist</quote>. The past tense is appropriate because
|
Update documentation on may/can/might:
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
Also update two error messages mentioned in the documenation to match.
2007-01-31 21:56:20 +01:00
|
|
|
next time the disk might not be full anymore or the file in question might
|
2009-06-04 20:33:08 +02:00
|
|
|
exist.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2007-02-01 21:28:08 +01:00
|
|
|
The second form indicates that the functionality of opening the named file
|
2003-05-19 23:38:24 +02:00
|
|
|
does not exist at all in the program, or that it's conceptually
|
|
|
|
impossible. The present tense is appropriate because the condition will
|
2009-06-04 20:33:08 +02:00
|
|
|
persist indefinitely.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: Granted, the average user will not be able to draw great
|
|
|
|
conclusions merely from the tense of the message, but since the language
|
2009-06-04 20:33:08 +02:00
|
|
|
provides us with a grammar we should use it correctly.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Type of the Object</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
When citing the name of an object, state what kind of object it is.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2004-02-17 03:53:03 +01:00
|
|
|
Rationale: Otherwise no one will know what <quote>foo.bar.baz</>
|
|
|
|
refers to.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
|
|
|
<title>Brackets</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Square brackets are only to be used (1) in command synopses to denote
|
|
|
|
optional arguments, or (2) to denote an array subscript.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: Anything else does not correspond to widely-known customary
|
|
|
|
usage and will confuse people.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Assembling Error Messages</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
When a message includes text that is generated elsewhere, embed it in
|
|
|
|
this style:
|
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
could not open file %s: %m
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: It would be difficult to account for all possible error codes
|
|
|
|
to paste this into a single smooth sentence, so some sort of punctuation
|
|
|
|
is needed. Putting the embedded text in parentheses has also been
|
|
|
|
suggested, but it's unnatural if the embedded text is likely to be the
|
2009-06-04 20:33:08 +02:00
|
|
|
most important part of the message, as is often the case.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Reasons for Errors</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Messages should always state the reason why an error occurred.
|
|
|
|
For example:
|
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
BAD: could not open file %s
|
|
|
|
BETTER: could not open file %s (I/O failure)
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
If no reason is known you better fix the code.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Function Names</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Don't include the name of the reporting routine in the error text. We have
|
|
|
|
other mechanisms for finding that out when needed, and for most users it's
|
|
|
|
not helpful information. If the error text doesn't make as much sense
|
2009-06-04 20:33:08 +02:00
|
|
|
without the function name, reword it.
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
Wording cleanup for error messages. Also change can't -> cannot.
Standard English uses "may", "can", and "might" in different ways:
may - permission, "You may borrow my rake."
can - ability, "I can lift that log."
might - possibility, "It might rain today."
Unfortunately, in conversational English, their use is often mixed, as
in, "You may use this variable to do X", when in fact, "can" is a better
choice. Similarly, "It may crash" is better stated, "It might crash".
2007-02-01 20:10:30 +01:00
|
|
|
BAD: pg_atoi: error in "z": cannot parse "z"
|
2004-12-13 19:05:10 +01:00
|
|
|
BETTER: invalid input syntax for integer: "z"
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Avoid mentioning called function names, either; instead say what the code
|
|
|
|
was trying to do:
|
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
BAD: open() failed: %m
|
|
|
|
BETTER: could not open file %s: %m
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
If it really seems necessary, mention the system call in the detail
|
|
|
|
message. (In some cases, providing the actual values passed to the
|
|
|
|
system call might be appropriate information for the detail message.)
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: Users don't know what all those functions do.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Tricky Words to Avoid</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Unable</title>
|
|
|
|
<para>
|
|
|
|
<quote>Unable</quote> is nearly the passive voice. Better use
|
|
|
|
<quote>cannot</quote> or <quote>could not</quote>, as appropriate.
|
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Bad</title>
|
|
|
|
<para>
|
|
|
|
Error messages like <quote>bad result</quote> are really hard to interpret
|
|
|
|
intelligently. It's better to write why the result is <quote>bad</quote>,
|
2009-06-04 20:33:08 +02:00
|
|
|
e.g., <quote>invalid format</quote>.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Illegal</title>
|
|
|
|
<para>
|
|
|
|
<quote>Illegal</quote> stands for a violation of the law, the rest is
|
|
|
|
<quote>invalid</quote>. Better yet, say why it's invalid.
|
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Unknown</title>
|
|
|
|
<para>
|
|
|
|
Try to avoid <quote>unknown</quote>. Consider <quote>error: unknown
|
|
|
|
response</quote>. If you don't know what the response is, how do you know
|
|
|
|
it's erroneous? <quote>Unrecognized</quote> is often a better choice.
|
2009-06-04 20:33:08 +02:00
|
|
|
Also, be sure to include the value being complained of.
|
2003-05-19 23:38:24 +02:00
|
|
|
<programlisting>
|
2004-12-13 19:05:10 +01:00
|
|
|
BAD: unknown node type
|
|
|
|
BETTER: unrecognized node type: 42
|
2003-05-19 23:38:24 +02:00
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Find vs. Exists</title>
|
|
|
|
<para>
|
|
|
|
If the program uses a nontrivial algorithm to locate a resource (e.g., a
|
|
|
|
path search) and that algorithm fails, it is fair to say that the program
|
|
|
|
couldn't <quote>find</quote> the resource. If, on the other hand, the
|
|
|
|
expected location of the resource is known but the program cannot access
|
|
|
|
it there then say that the resource doesn't <quote>exist</quote>. Using
|
2009-06-04 20:33:08 +02:00
|
|
|
<quote>find</quote> in this case sounds weak and confuses the issue.
|
2003-05-19 23:38:24 +02:00
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
2007-02-01 22:28:34 +01:00
|
|
|
<formalpara>
|
2007-02-01 23:06:14 +01:00
|
|
|
<title>May vs. Can vs. Might</title>
|
2007-02-01 22:28:34 +01:00
|
|
|
<para>
|
2009-04-27 18:27:36 +02:00
|
|
|
<quote>May</quote> suggests permission (e.g., "You may borrow my rake."),
|
2007-02-01 22:28:34 +01:00
|
|
|
and has little use in documentation or error messages.
|
2009-04-27 18:27:36 +02:00
|
|
|
<quote>Can</quote> suggests ability (e.g., "I can lift that log."),
|
|
|
|
and <quote>might</quote> suggests possibility (e.g., "It might rain
|
2007-02-01 23:06:14 +01:00
|
|
|
today."). Using the proper word clarifies meaning and assists
|
2007-02-01 22:28:34 +01:00
|
|
|
translation.
|
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
|
|
|
<formalpara>
|
|
|
|
<title>Contractions</title>
|
|
|
|
<para>
|
|
|
|
Avoid contractions, like <quote>can't</quote>; use
|
|
|
|
<quote>cannot</quote> instead.
|
|
|
|
</para>
|
|
|
|
</formalpara>
|
|
|
|
|
2003-05-19 23:38:24 +02:00
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
2011-01-29 19:00:18 +01:00
|
|
|
<title>Proper Spelling</title>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Spell out words in full. For instance, avoid:
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
spec
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
stats
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
parens
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
auth
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
xact
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
2000-02-02 17:25:04 +01:00
|
|
|
</para>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
|
|
|
<para>
|
|
|
|
Rationale: This will improve consistency.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</simplesect>
|
|
|
|
|
|
|
|
<simplesect>
|
|
|
|
<title>Localization</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Keep in mind that error message texts need to be translated into other
|
|
|
|
languages. Follow the guidelines in <xref linkend="nls-guidelines">
|
|
|
|
to avoid making life difficult for translators.
|
|
|
|
</para>
|
|
|
|
</simplesect>
|
|
|
|
|
2000-02-02 17:25:04 +01:00
|
|
|
</sect1>
|
2003-05-19 23:38:24 +02:00
|
|
|
|
2000-02-02 17:25:04 +01:00
|
|
|
</chapter>
|