Skip to content

Commit 201d903

Browse files
committed
Conventions for error messages
1 parent 4c0e9fb commit 201d903

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/interoperability.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,24 @@ impl Display for DoError { /* ... */ }
266266
impl Error for DoError { /* ... */ }
267267
```
268268

269+
The error message given by the `Display` representation of an error type should
270+
be lowercase without trailing punctuation, and typically concise.
271+
269272
### Examples from the standard library
270273

271274
- [`ParseBoolError`] is returned when failing to parse a bool from a string.
272275

273276
[`ParseBoolError`]: https://doc.rust-lang.org/std/str/struct.ParseBoolError.html
274277

278+
### Examples of error messages
279+
280+
- "unexpected end of file"
281+
- "provided string was not \`true\` or \`false\`"
282+
- "invalid IP address syntax"
283+
- "second time provided was later than self"
284+
- "invalid UTF-8 sequence of {} bytes from index {}"
285+
- "environment variable was not valid unicode: {:?}"
286+
275287

276288
<a id="c-num-fmt"></a>
277289
## Binary number types provide `Hex`, `Octal`, `Binary` formatting (C-NUM-FMT)

0 commit comments

Comments
 (0)