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

Replace file helper #2

Merged
merged 8 commits into from
Feb 19, 2025
Merged

Replace file helper #2

merged 8 commits into from
Feb 19, 2025

Conversation

stefanvogel
Copy link
Collaborator

No description provided.

Copy link

@chaitu20000 chaitu20000 left a comment

Choose a reason for hiding this comment

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

Replaced file helper with new implementation

import os

def file_helper(path: str, mode: str):
try:
file = open(path, mode)
return file
except FileNotFoundError:
raise IOError(f"File not found: {path}")
except PermissionError:
raise IOError(f"Permission denied: {path}")
except Exception as e:
raise IOError(f"Error handling file {path}: {e}")

@stefanvogel
Copy link
Collaborator Author

stefanvogel commented Feb 18, 2025

Replaced file helper with new implementation

import os

def file_helper(path: str, mode: str): try: file = open(path, mode) return file except FileNotFoundError: raise IOError(f"File not found: {path}") except PermissionError: raise IOError(f"Permission denied: {path}") except Exception as e: raise IOError(f"Error handling file {path}: {e}")

@chaitu20000 Not a bad idea to handle more exceptions and raise IOError uniformly for all.

@stefanvogel stefanvogel merged commit 517d079 into main Feb 19, 2025
22 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.

4 participants