Skip to content

Commit 5cbe030

Browse files
committed
Merge branch 'jc/doc-error-message-guidelines'
Developer documentation update. * jc/doc-error-message-guidelines: CodingGuidelines: a handful of error message guidelines
2 parents a326688 + 168ebb7 commit 5cbe030

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
@@ -703,16 +703,30 @@ Program Output
703703

704704
Error Messages
705705

706-
- Do not end error messages with a full stop.
706+
- Do not end a single-sentence error message with a full stop.
707707

708708
- Do not capitalize the first word, only because it is the first word
709-
in the message ("unable to open %s", not "Unable to open %s"). But
709+
in the message ("unable to open '%s'", not "Unable to open '%s'"). But
710710
"SHA-3 not supported" is fine, because the reason the first word is
711711
capitalized is not because it is at the beginning of the sentence,
712712
but because the word would be spelled in capital letters even when
713713
it appeared in the middle of the sentence.
714714

715-
- Say what the error is first ("cannot open %s", not "%s: cannot open")
715+
- Say what the error is first ("cannot open '%s'", not "%s: cannot open").
716+
717+
- Enclose the subject of an error inside a pair of single quotes,
718+
e.g. `die(_("unable to open '%s'"), path)`.
719+
720+
- Unless there is a compelling reason not to, error messages from
721+
porcelain commands should be marked for translation, e.g.
722+
`die(_("bad revision %s"), revision)`.
723+
724+
- Error messages from the plumbing commands are sometimes meant for
725+
machine consumption and should not be marked for translation,
726+
e.g., `die("bad revision %s", revision)`.
727+
728+
- BUG("message") are for communicating the specific error to developers,
729+
thus should not be translated.
716730

717731

718732
Externally Visible Names

0 commit comments

Comments
 (0)