From 6303551cb8a5a84ea78c1a15fda9770f04f636ee Mon Sep 17 00:00:00 2001 From: Alex Kladov Date: Mon, 19 Jun 2023 13:01:47 +0100 Subject: internal: use consistent style for error handling --- docs/dev/style.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/dev') 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 -- cgit 1.4.1-3-g733a5