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

migrate error handling to anyhow #26

Merged
merged 2 commits into from
Nov 16, 2023
Merged

migrate error handling to anyhow #26

merged 2 commits into from
Nov 16, 2023

Conversation

dongsupark
Copy link
Member

@dongsupark dongsupark commented Nov 9, 2023

Add a new dependency of anyhow crate, to use flexible concrete error handling mechanism, instead of the native error types.

To follow error handling convention of anyhow, insert .context to add detailed message of error context when returning from functions.
In case of an immediate error exit, use a bail! macro.

Note, main functions and unit tests stay untouched if possible.

Fixes #25

Add a new dependency of `anyhow` crate, to use flexible concrete
error handling mechanism, instead of the native error types.
To follow error handling convention of anyhow, insert `.context` to add
detailed message of error context when returning from functions.

In case of an immediate error exit, use a `bail!` macro.

Note, main functions and unit tests stay untouched if possible.
@dongsupark dongsupark marked this pull request as ready for review November 16, 2023 15:13
Copy link
Member

@pothos pothos left a comment

Choose a reason for hiding this comment

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

Some improvements would be good: Instead of writing errors to the terminal from functions that return Options it would be better to return Results.
Also, the dummy signature error is printed too prominently, we skip over it but it looks like the program crashed if you don't pay attention to the last line

Parsed and verified signature data from file "/var/tmp/outdir/.unverified/oem-ami.gz"

which indicates that it was successful.

@pothos
Copy link
Member

pothos commented Nov 16, 2023

Doing it in a follow-up is better, thus the approval.

@dongsupark
Copy link
Member Author

Thanks. I created a separate issue for the improvement of error handling. #28

@dongsupark dongsupark merged commit 9d65824 into trunk Nov 16, 2023
1 check passed
@dongsupark dongsupark deleted the dongsu/error-anyhow branch November 16, 2023 16:33
dongsupark added a commit to flatcar/scripts that referenced this pull request Dec 7, 2023
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.

Use anyhow for error handling
2 participants