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

Case studies #1

Open
nrc opened this issue Nov 8, 2022 · 1 comment
Open

Case studies #1

nrc opened this issue Nov 8, 2022 · 1 comment

Comments

@nrc
Copy link
Owner

nrc commented Nov 8, 2022

I want to add some case studies to the error design section. Ideas:

  • compiler/parser errors
  • a prototype library
  • a library with network client or something
  • a CLI app
@Velfi
Copy link

Velfi commented Nov 9, 2022

In case it's helpful, we (the AWS SDK for Rust team) just put a lot of thought into how we expose errors to users of our libraries. @jdisanti wrote an RFC that you can read here.

John put forth the following goals:

  1. Errors are forwards compatible, and changes to errors are backwards compatible
  2. Errors are idiomatic and ergonomic. It is easy to match on them and extract additional information for cases where that's useful. The type system prevents errors from being used incorrectly (for example, incorrectly retrieving context for a different error variant)
  3. Error messages are easy to debug
  4. Errors implement best practices with Rust's Error trait (for example, implementing the optional source() function where possible)

An we ended up dividing 99% of our existing errors into two categories:

  • Actionable: Errors that can/should influence program flow; where it's useful to do different work based on additional error context or error variant information
  • Informative: Errors that inform that something went wrong, but where it's not useful to match on the error to change program flow

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

No branches or pull requests

2 participants