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

improove OPNsenseConfig errorhandling #20

Merged
merged 1 commit into from
Sep 12, 2023
Merged

improove OPNsenseConfig errorhandling #20

merged 1 commit into from
Sep 12, 2023

Conversation

rekup
Copy link
Contributor

@rekup rekup commented Sep 11, 2023

Currently, if an exception is occurring during a module execution within the context of a OPNsenseConfig object, python calls __exit__ which results in a misleading error message Config has changed. Cannot exit without saving..
If for example we try to update the config by modifying it but we did not specify become: true we get the following error message:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: RuntimeError: Config has changed. Cannot exit without saving.
fatal: [opnsense]: FAILED! 

By first checking the exception type, we can make sure there was no exception and then proceed with the check for a changed config. If there was an exception, we will return it's type and value:

TASK [test] **************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: PermissionError: Exception occurred: [Errno 13] Permission denied: '/conf/config.xml'

Copy link
Contributor

@DonGiovanni83 DonGiovanni83 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 👍🏼

@rekup rekup merged commit 441e23c into puzzle:main Sep 12, 2023
30 checks passed
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