Incorporate RuntimeError exception handling in file reading operations
soaressgabriel opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
We are encountering some issues when reading files from the disk in our Python project of a distributed hydrological model using PCRaster. The system lacks proper error handling for file reading, which can cause unexpected crashes if, for example, a file is missing, corrupt, or not accessible due to permissions issues.
Describe the solution you'd like
To improve the robustness and user experience of our system, I suggest incorporating try-exception handling specifically for RuntimeError
during file reading operations. This will allow the system to catch any issues during the file read operation and handle them gracefully, either by logging an error message or prompting the user for a different file, instead of crashing unexpectedly.
Describe alternatives you've considered
An alternative approach could be to check the file's existence and permissions before attempting to read it. However, this would not cover other possible read issues, such as file corruption. Hence, implementing exception handling for RuntimeError
would provide a more comprehensive solution.
Additional context
This change would increase the system's stability and make it more user-friendly, particularly for new users who might not be familiar with the file requirements. It also aligns with best practices for software development, making our code more robust and reliable.