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

Improve error handling #82

Open
KokaKiwi opened this issue Sep 27, 2024 · 0 comments
Open

Improve error handling #82

KokaKiwi opened this issue Sep 27, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@KokaKiwi
Copy link
Contributor

KokaKiwi commented Sep 27, 2024

Is your feature request related to a problem? Please describe.

Error reporting is a big part in user interaction, thus it would be greatly beneficial to improve error handling.
As in:

  • Removing as much panic! or .unwrap/.expect as possible, both because panic is not a good error handling in Rust, as stated in Chapter 9: Error Handling of The Rust Book, and because panic error messages are generally hard to read for users
  • Providing as much useful information to the user in case of an error happening for helping them to fix it.

Describe the solution you'd like

  • Use as much as possible Result when doing error-handling (up to main which can return a Result btw!):
    • Using panic!/.unwrap/.expect only when getting hard errors which cannot be handled in a sane way (defined as "unrecoverable errors")
  • Use helpful crates for doing nice error-handling, with these ones as suggestions:
    • miette: Kind of a successor to anyhow and many other error-reporting crates, became one of the most used crates in this category for some time already and with many contributors/maintenance:

      Fancy diagnostic reporting library and protocol for us mere mortals who aren't compiler hackers

    • thiserror: A really helpful crate which help designing app-specific errors without the hassle of implementing Error by hand, also integrate really fine with miette
    • tracing-error: Could be optional here, but it brings a nice bridge between the tracing crate and error-handling code.

Additional context

Kind of a repetition, but the Rust Book chapter on error handling is a really good lecture: Chapter 9: Error Handling of The Rust Book

@KokaKiwi KokaKiwi added the enhancement New feature or request label Sep 27, 2024
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

No branches or pull requests

1 participant