Skip to content

Better error handling #466

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

Merged
merged 10 commits into from
Jul 16, 2021
Merged

Better error handling #466

merged 10 commits into from
Jul 16, 2021

Conversation

o2sh
Copy link
Owner

@o2sh o2sh commented Jul 11, 2021

The crate error-chain used by onefetch for error handling seems to no longer be maintained.

Anyhow seems to be a good candidate for structuring errors 🤔.

At the same time, this might be an opportunity to improve and homogenize the way we handle/report errors.

  • Replace error-chain with anyhow
  • Homogenize/improve error handling/reporting
  • Avoid the use of unwrap() whenever possible

@o2sh o2sh added enhancement New feature or request discussion labels Jul 11, 2021
@o2sh o2sh changed the title Better error handling -- WIP Better error handling Jul 11, 2021
Copy link
Contributor

@HallerPatrick HallerPatrick left a comment

Choose a reason for hiding this comment

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

Really nice work there! I like the idea of context. They will help a lot with improving error handling/reporting

@spenserblack
Copy link
Collaborator

@o2sh Would you want my review now or when the PR is no longer a draft?

@o2sh
Copy link
Owner Author

o2sh commented Jul 12, 2021

@o2sh Would you want my review now or when the PR is no longer a draft?

If you already have suggestions/comments, the sooner the better 🙏. I chose to keep this PR as a draft because its scope is still not very clear at the moment as it may include more refactoring beside the switch to anyhow.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Left some suggestions. All of them are style preference, they shouldn't change the behavior.

One thing I noticed was that you used with_context(|| "foo") a lot. Is there a reason to use that over context("foo")?

@o2sh
Copy link
Owner Author

o2sh commented Jul 13, 2021

One thing I noticed was that you used with_context(|| "foo") a lot. Is there a reason to use that over context("foo")?

Apparently, it results in better performance in an error-free scenario.

@o2sh o2sh marked this pull request as ready for review July 14, 2021 02:08
@o2sh o2sh merged commit 9466f26 into main Jul 16, 2021
@o2sh o2sh deleted the refacto/use-anyhow branch July 16, 2021 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants