Better implementation
- Dominant language
- Rust
- Stars
- 7
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Add a trait extension to results to annotate errors with a location. Then allow users to define:
```rust
impl From> for UserErrorType {
///
}
```
Users can then use any location type they want, but don't need to use or store the annotated error type outside of the from implementation. For example:
```rust
// implementation:
impl From> for Error {
fn from(annotated: Annotated) -> Error {
Error::Io{io_error: annotated.error, path: annotate.annotation.to_owned()}
}
}
// use:
fn main() -> Result<(), Error> {
let file = Path::new("foo")
File::open(file).annotate(file).into()
}
```
Contributor guide
Research direction
Start by locating the existing result and error-handling types in the Rust crate and read how errors are currently converted. Define the expected Annotated API and trait extension from the examples, then verify that a user can implement From for the annotated error and preserve the underlying error and location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100