casey / casey/oi

Better implementation

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.