Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved error handling #37

Closed
danieleades opened this issue Apr 18, 2020 · 0 comments · Fixed by #39
Closed

improved error handling #37

danieleades opened this issue Apr 18, 2020 · 0 comments · Fixed by #39
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@danieleades
Copy link
Contributor

the error handling can be improved.

taking inspiration from

The idea is that you really have two classes of errors

  • local errors - expected in normal operation. usually handled 'locally'
  • global errors- some serious issue that should not occur during normal operation. These should generally be propagated all the way up

The idea is to 'double-wrap' the Results such that the inner Errors encode 'local' errors (such as validation errors), while the outer Errors encode 'showstoppers' (such as IO errors).

The downside is the error types get a little ugly (Result<Result<T, LocalError>, GlobalError>).

the upside is that in calling code, a consumer of the error can use '?' to propagate and unwrap the global error upwards, and explicitly handle the so-called local error with a match statement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant