Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added try-except for error handling:
In both handleAllFlag and find_duplicates, I added a try-except block around the future.result() call. If an exception occurs, it catches the error, logs a message with the file path, and continues processing other files.
Description
The updated error handling in the code ensures that any errors encountered while processing files are caught and handled gracefully, without crashing the program. Specifically, it does the following:
Try-Except Block for Each File:
For each file being processed in both the handleAllFlag and find_duplicates functions, the program attempts to process the file inside a try block.
If any exception occurs (e.g., permission issues, file is in use), the except block catches it.
Error Reporting:
When an error occurs, the program prints an informative message to the user. This message includes the file path that caused the error and a description of the error.
This helps users understand which file caused the issue and what went wrong (e.g., permission denied, file not found).
Prevents Crashes:
By handling exceptions, the program can continue processing other files even if some files cause errors, improving robustness.
Type of change
I have added error handling to fix a specific issue in the existing code where the program crashes due to unhandled exceptions (e.g., permission issues or files in use). This change improves the stability and robustness of the application without introducing new features or breaking changes.
Checklist