diff options
| author | Alex Kladov <aleksey.kladov@gmail.com> | 2023-06-19 13:01:47 +0100 |
|---|---|---|
| committer | Alex Kladov <aleksey.kladov@gmail.com> | 2023-06-19 13:01:47 +0100 |
| commit | 6303551cb8a5a84ea78c1a15fda9770f04f636ee (patch) | |
| tree | 57c372a51016ab2741279f0409b419d5176343a7 /docs/dev | |
| parent | 49318bbae7a419743e44245fa76c4aca803bae10 (diff) | |
| download | rust-6303551cb8a5a84ea78c1a15fda9770f04f636ee.tar.gz rust-6303551cb8a5a84ea78c1a15fda9770f04f636ee.zip | |
internal: use consistent style for error handling
Diffstat (limited to 'docs/dev')
| -rw-r--r-- | docs/dev/style.md | 13 |
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 |
