Skip to content

Commit 168ebb7

Browse files
committed
CodingGuidelines: a handful of error message guidelines
It is more efficient to have something in the coding guidelines document to point at, when we want to review and comment on a new message in the codebase to make sure it "fits" in the set of existing messages. Let's write down established best practice we are aware of. Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 92999a4 commit 168ebb7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Documentation/CodingGuidelines

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,16 +689,30 @@ Program Output
689689

690690
Error Messages
691691

692-
- Do not end error messages with a full stop.
692+
- Do not end a single-sentence error message with a full stop.
693693

694694
- Do not capitalize the first word, only because it is the first word
695-
in the message ("unable to open %s", not "Unable to open %s"). But
695+
in the message ("unable to open '%s'", not "Unable to open '%s'"). But
696696
"SHA-3 not supported" is fine, because the reason the first word is
697697
capitalized is not because it is at the beginning of the sentence,
698698
but because the word would be spelled in capital letters even when
699699
it appeared in the middle of the sentence.
700700

701-
- Say what the error is first ("cannot open %s", not "%s: cannot open")
701+
- Say what the error is first ("cannot open '%s'", not "%s: cannot open").
702+
703+
- Enclose the subject of an error inside a pair of single quotes,
704+
e.g. `die(_("unable to open '%s'"), path)`.
705+
706+
- Unless there is a compelling reason not to, error messages from
707+
porcelain commands should be marked for translation, e.g.
708+
`die(_("bad revision %s"), revision)`.
709+
710+
- Error messages from the plumbing commands are sometimes meant for
711+
machine consumption and should not be marked for translation,
712+
e.g., `die("bad revision %s", revision)`.
713+
714+
- BUG("message") are for communicating the specific error to developers,
715+
thus should not be translated.
702716

703717

704718
Externally Visible Names

0 commit comments

Comments
 (0)