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

chore(nargo): report bubbled up errors using eyre #907

Merged
merged 3 commits into from
Feb 28, 2023
Merged

Conversation

TomAFrench
Copy link
Member

@TomAFrench TomAFrench commented Feb 24, 2023

Related issue(s)

Resolves #819
Resolves #686

Description

Summary of changes

Rather than explicitly writing errors to the console and then calling std::process::exit(1) we now wrap the bubbled up error in an anyhow::Result and just return it from main.

Dependency additions / changes

Added anyhow as dep of nargo.

Test additions / changes

Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt with default settings.
  • I have linked this PR to the issue(s) that it resolves.
  • I have reviewed the changes on GitHub, line by line.
  • I have ensured all changes are covered in the description.
  • This PR requires documentation updates when merged.

Additional context

@Ethan-000
Copy link
Contributor

I think this also resolves #686

@TomAFrench
Copy link
Member Author

TomAFrench commented Feb 24, 2023

Ah, thanks yes it does (as we no longer colour the terminal on errors)

Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

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

I'm not sure if it's worth it to add a new dependency just to avoid writing:

if let Err(err) = result {
    err.write()
}

@phated
Copy link
Contributor

phated commented Feb 24, 2023

I usually agree with @jfecher about adding dependencies but I think getting anyhow into the project would be helpful for the future. It's one of the (surprisingly) few crates that I've seen recommended by everyone (probably just thiserror and anyhow!)

@TomAFrench
Copy link
Member Author

Actually, it looks like our existing dependency of color_eyre can perform much the same role as anyhow would here.

@TomAFrench TomAFrench changed the title chore(nargo): report bubbled up errors using anyhow chore(nargo): report bubbled up errors using eyre Feb 26, 2023
kevaundray
kevaundray previously approved these changes Feb 27, 2023
@TomAFrench TomAFrench added this pull request to the merge queue Feb 28, 2023
Merged via the queue into master with commit e87ce66 Feb 28, 2023
@TomAFrench TomAFrench deleted the anyhow branch February 28, 2023 15:32
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.

Replace thiserror in nargo with anyhow nargo colours subsequent cli lines red after encountering an error
5 participants