oxidecomputer / oxidecomputer/crucible
`anyhow::Result` shouldn't be used for libraries
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 260
- Forks
- 34
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 8
Description
As per https://github.com/oxidecomputer/meta/blob/master/engineering/rust-crate-zoo.adoc#anyhow:
The anyhow crate provides useful error handling for applications. The main features are:
anyhow::Result<T> as a general return type, with the neccesary impls to be able to "`?` all the things." A .context method to help troubleshooting later.This lines up with application use-cases because in applications, you are often collecting errors from your dependencies, and need to combine and/or propogate them upwards. You often are not writing your own bespoke error types.
Anyhow requires an allocator, and therefore, is not appropriate for most of Oxide’s no_std code.
If you’re writing a library, see thiserror instead.
and https://github.com/oxidecomputer/meta/blob/master/engineering/rust-crate-zoo.adoc#thiserror:
The thiserror crate provides a nice derive for the Error trait. This makes it very useful when writing a library, as you’ll probably be crafting specific errors to return to your callers.
We need to switch upstairs code to return the standard Result instead of anyhow::Result.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the “upstairs” code and all uses of anyhow::Result in the repository, then review the referenced Rust crate guidance. The work is done when the relevant library code returns standard Result types instead of anyhow::Result, with existing behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100