-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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}")
@chaitu20000 Not a bad idea to handle more exceptions and raise IOError uniformly for all. |
No description provided.