Skip to content

fix: narrow bare except Exception in VS Code settings merge - #3844

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/utils-narrow-exception
Open

fix: narrow bare except Exception in VS Code settings merge#3844
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/utils-narrow-exception

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Summary

Narrow bare except Exception to specific exception types to let programming errors propagate.

Changes

  • _utils.py: Replace except Exception with (OSError, ValueError, KeyError)

Replace overly broad except Exception with (OSError, ValueError, KeyError)
to let programming errors like TypeError or AttributeError propagate while
still handling expected I/O and parse errors gracefully.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Narrows VS Code settings merge error handling so unexpected failures propagate.

Changes:

  • Replaces broad exception handling with selected exception types.
Show a summary per file
File Description
src/specify_cli/_utils.py Narrows settings merge exception handling.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

src/specify_cli/_utils.py:216

  • KeyError is still a programming-error class, and no operation on this path uses an unchecked dictionary lookup: JSON5 parse failures are ValueError, filesystem operations raise OSError, and merge_json_files guards membership before indexing. Catching KeyError therefore still suppresses the kind of unexpected defect the PR says should propagate; limit this handler to the expected I/O and parse failures.
    except (OSError, ValueError, KeyError) as e:
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Medium

Comment thread src/specify_cli/_utils.py
log("Copied (no existing settings.json):", "blue")

except Exception as e:
except (OSError, ValueError, KeyError) as e:
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.

3 participants