Skip to content

refactor: adopt EAFP and explicit error handling for template file - #45

Open
Stephen0512 wants to merge 2 commits into
Domain-Connect:masterfrom
Stephen0512:master
Open

refactor: adopt EAFP and explicit error handling for template file#45
Stephen0512 wants to merge 2 commits into
Domain-Connect:masterfrom
Stephen0512:master

Conversation

@Stephen0512

Copy link
Copy Markdown

Identified Issues

The current DomainConnect.__init__ uses os.access() to check file permissions before opening, which creates a security risk due to race conditions. The Python documentation recommends using EAFP (Easier to Ask for Forgiveness than Permission) link to avoid this.

Proposed Changes

  • Replace os.access() and other pre-checks with EAFP by directly attempting to open the file and catching exceptions.
  • Improve error handling by raising specific exceptions (e.g., FileNotFoundError, PermissionError) with clear messages.

The issue was identified during an ongoing research project.

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.

1 participant