diff options
| author | har7an <99636919+har7an@users.noreply.github.com> | 2022-11-09 18:01:36 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-09 18:01:36 +0000 |
| commit | 49b831c032aa4d7f770847ba0c03050a09c80fe1 (patch) | |
| tree | 9aa6efdc4bd85a47eb08914cd45afc82ad325a24 /CONTRIBUTING.md | |
| parent | docs(changelog): termwiz bump (diff) | |
| download | sl0ppij-49b831c032aa4d7f770847ba0c03050a09c80fe1.tar.gz sl0ppij-49b831c032aa4d7f770847ba0c03050a09c80fe1.tar.xz sl0ppij-49b831c032aa4d7f770847ba0c03050a09c80fe1.zip | |
docs: Improve error handling docs (#1919)
* docs: Improve error handling docs
and add more TL;DRs and new sections about handling specific errors, and
logging errors.
* contributing: Add more coding tips
Diffstat (limited to 'CONTRIBUTING.md')
| -rw-r--r-- | CONTRIBUTING.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 59159a98..87eca094 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -124,8 +124,23 @@ something interesting to work on and guide through. - Generate ad-hoc errors with `anyhow!(<SOME MESSAGE>)` - *Further reading*: [See here][error-docs-result] +### Logging errors + +- When there's a `Result` type around, use `.non_fatal()` on that instead of `log::error!` +- When there's a `Err` type around, use `Err::<(), _>(err).non_fatal()` +- Also attach context before logging! +- *Further reading*: [See here][error-docs-logging] + +### Adding Concrete Errors, Handling Specific Errors + +- Add a new variant to `zellij_utils::errors::ZellijError`, if needed +- Use `anyhow::Error::downcast_ref::<ZellijError>()` to recover underlying errors +- *Further reading*: [See here][error-docs-zellijerror] + [error-docs-context]: https://github.com/zellij-org/zellij/blob/main/docs/ERROR_HANDLING.md#attaching-context [error-docs-result]: https://github.com/zellij-org/zellij/blob/main/docs/ERROR_HANDLING.md#converting-a-function-to-return-a-result-type +[error-docs-logging]: https://github.com/zellij-org/zellij/blob/main/docs/ERROR_HANDLING.md#logging-errors +[error-docs-zellijerror]: https://github.com/zellij-org/zellij/blob/main/docs/ERROR_HANDLING.md#adding-concrete-errors-handling-specific-errors ## Filing Issues |
