Skip to content

Commit 4d28251

Browse files
committed
Merge branch 'jc/doc-error-message-guidelines' into seen
* jc/doc-error-message-guidelines: CodingGuidelines: a handful of error message guidelines
2 parents d19d54a + 5ad9fff commit 4d28251

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Documentation/CodingGuidelines

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,16 +703,29 @@ 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 the
721+
Porcelain command should be marked for `_("translation")`.
722+
723+
- Error messages from the plumbing commands are sometimes meant for
724+
machine consumption and should not be marked for `_("translation")`
725+
to keep them 'grep'-able.
726+
727+
- BUG("message") are for communicating the specific error to
728+
developers, and not to be translated.
716729

717730

718731
Externally Visible Names

0 commit comments

Comments
 (0)