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

main: Correct defer handling in main entrypoint. #351

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Sep 12, 2023

This is rebased on #350.

This refactors the main code into a separate function that returns an error instead of invoking os.Exit directly to ensure that the defers that are setup prior to the exits are run as intended.

The main func will now exit with the non-zero error code when an error is returned from the refactored separate func.

This removes the unused error return from the newConfigParser function
and updates the callers accordingly.
Copy link
Member

@jholdstock jholdstock left a comment

Choose a reason for hiding this comment

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

Looks good but needs rebase.

This refactors the main code into a separate function that returns an
error instead of invoking os.Exit directly to ensure that the defers
that are setup prior to the exits are run as intended.

The main func will now exit with the non-zero error code when an error
is returned from the refactored separate func.
@jholdstock jholdstock merged commit 433a31b into decred:master Sep 12, 2023
2 checks passed
@davecgh davecgh deleted the main_no_os_exit_after_defer branch September 12, 2023 06:19
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