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

wxGUI: Refactored try-except block to be more robust in dialogs.py #4383

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

arohanajit
Copy link
Contributor

Description

This PR is more of a suggestion since I thought this would be a better way to handle this instead of a try-except block. It modifies the GetSQLString method in the DisplayAttributesDialog class to improve how it retrieves values from widgets. The changes make the code more robust and explicit in handling different widget types.

Changes

  • Replace bare except clause with explicit checks for GetValue() and GetLabel() methods
  • Add error handling for widgets that have neither method

Reason for Changes

The original code used a bare except clause to handle potential AttributeErrors when trying to call GetValue() or GetLabel() on widgets. This approach was not robust and could potentially hide unexpected errors. The new implementation explicitly checks for the presence of these methods and raises an AttributeError if neither are present.

@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python labels Sep 25, 2024
Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>
@petrasovaa petrasovaa merged commit 845dfd0 into OSGeo:main Sep 26, 2024
26 checks passed
@petrasovaa petrasovaa added this to the 8.5.0 milestone Sep 26, 2024
@arohanajit arohanajit deleted the dbmgr-dialogs branch September 26, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants