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

feat: error reporting with eyre #240

Merged
merged 8 commits into from
Oct 8, 2024
Merged

feat: error reporting with eyre #240

merged 8 commits into from
Oct 8, 2024

Conversation

dangush
Copy link
Contributor

@dangush dangush commented Oct 4, 2024

Closes #134

The custom error type using thiserror that we had was not effective for handling errors in a descriptive manner.

I've learned now that the advice is to use anyhow/eyres for adding context to backtraces of errors when writing application logic, and using thiserror for custom error types when writing libraries.

So I removed our error.rs file and replaced all instances of Error with eyres::{Result, Report}.

I also modified the CwClient CLI impl to use eyres instead of anyhow for compatibility, and to throw errors when the underlying binary can't be found.

Example:
image

Copy link
Member

@hu55a1n1 hu55a1n1 left a comment

Choose a reason for hiding this comment

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

Awesome! 👏
Tested with common mistakes in all CLI commands and errors look more expressive. Pushed some cleanup and fixed a regression (not originating from this PR).

@hu55a1n1 hu55a1n1 merged commit df40e59 into main Oct 8, 2024
7 of 8 checks passed
@hu55a1n1 hu55a1n1 deleted the dangush/better-errors branch October 8, 2024 08:53
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.

Custom errors in Quartz CLI
2 participants