about summary refs log tree commit diff
path: root/docs/dev
diff options
context:
space:
mode:
authorAlex Kladov <aleksey.kladov@gmail.com>2023-06-19 13:01:47 +0100
committerAlex Kladov <aleksey.kladov@gmail.com>2023-06-19 13:01:47 +0100
commit6303551cb8a5a84ea78c1a15fda9770f04f636ee (patch)
tree57c372a51016ab2741279f0409b419d5176343a7 /docs/dev
parent49318bbae7a419743e44245fa76c4aca803bae10 (diff)
downloadrust-6303551cb8a5a84ea78c1a15fda9770f04f636ee.tar.gz
rust-6303551cb8a5a84ea78c1a15fda9770f04f636ee.zip
internal: use consistent style for error handling
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/style.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md
index d2a03fba40d..786127639ce 100644
--- a/docs/dev/style.md
+++ b/docs/dev/style.md
@@ -869,6 +869,19 @@ type   -> ty
 
 **Rationale:** consistency.
 
+## Error Handling Trivia
+
+Use `anyhow::Result` rather than just `Result`.
+
+**Rationale:** makes it immediately clear what result that is.
+
+Use `anyhow::format_err!` rather than `anyhow::anyhow`.
+
+**Rationale:** consistent, boring, avoids stuttering.
+
+There's no specific guidance on the formatting of error messages, see [anyhow/#209](https://github.com/dtolnay/anyhow/issues/209).
+Do not end error and context messages with `.` though. 
+
 ## Early Returns
 
 Do use early returns