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

fix: Refactor error handling to leverage thiserror's automatic Displa… #329

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

mdqst
Copy link
Contributor

@mdqst mdqst commented Dec 17, 2024

This update simplifies error handling by removing the manual implementation of the Display trait and relying on thiserror's capabilities to automatically generate it.


What has been changed?

  • Removed the manual Display implementations for all error enums.
  • Added the #[error(...)] attribute to each error variant to define error descriptions directly.
  • Ensured that #[from] is properly used for error conversions, reducing boilerplate code.

Why is this better?

  • thiserror automatically implements the Display trait, ensuring consistency and simplifying error handling.
  • The code is now cleaner and free from unnecessary boilerplate.
  • Error descriptions are explicitly defined using #[error(...)], making the code easier to read and maintain.
  • The implementation now adheres to best practices for error handling with thiserror.

This refactor not only simplifies the code but also ensures that all errors are formatted and handled in an idiomatic way.

Copy link
Contributor

@sjudson sjudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice cleanup, thanks.

@sjudson sjudson merged commit 315938c into nexus-xyz:main Dec 18, 2024
9 checks passed
sjudson pushed a commit that referenced this pull request Feb 5, 2025
* fix

* fix test

* move opt level test

* split up tests
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

Successfully merging this pull request may close these issues.

2 participants