Fix: Enhanced Error Handling and Feedback for CSV Import#69
Open
RyanMarr wants to merge 4 commits intoCesarBianchi:mainfrom
Open
Fix: Enhanced Error Handling and Feedback for CSV Import#69RyanMarr wants to merge 4 commits intoCesarBianchi:mainfrom
RyanMarr wants to merge 4 commits intoCesarBianchi:mainfrom
Conversation
## Motivation
The CSV Import feature had a few "silent failure" modes that made debugging dificult for users:
1. **Swallowed Exceptions**: Critial `IOException` and `ParseException` errors during the pre-check phase (in `getItemFromInstance`) were caught but not logged or reported, leading to incomplete data loading.
2. **Blank Error Dialog**: A logic error in `MainWindow.java` caused the import result to be overwritten by an empty "final result" object, resulting in a blank error dialog if the pre-check failed.
3. **Silent Execution Failures**: If the import process crashed (e.g., `RuntimeException`) or failed during the actual update loop, the errors were not aggregated or displayed to the user.
4. **UI Feedback**: The UI would appear frozen during the pre-check phase.
## Changes
### `JellyfinImportMetadata.java`
- **Pre-check**: Modified `startPreCheck` to catch generic `Exception`s and propagate them to the result object.
- **Logging**: In `getItemFromInstance`, exceptions are now explicitly logged to the differences log file (and system logger) instead of being ignored.
- **Execution Debugging**: Refactored `startImport` to:
- Wrap the iteration loop in a `try-catch` block to handle unexpected crashes.
- Use a `StringBuilder` to aggregate specific error messages for failed items (e.g., "Failed to refresh folder ID...").
- Include this aggregated report in the final `JellyfinResponseStandard` message if the import fails.
### `MainWindow.java`
- **Progress Indicator**: Added a modal "Checking CSV..." `JDialog` with an indeterminate progress bar during the pre-check phase to indicate activity.
- **Logic Fix**: Fixed the bug where `processResult` was unconditionally overwritten by `importCSV.getProcessFinalResult()` (which was empty at that stage). Now it only updates after a successful import run.
- **Worker Handling**: Added a `try-catch` block around `worker.get()` in the done() method to ensure that any exceptions thrown on the background thread are displayed to the user via a `JOptionPane`.
## Testing
- Verified that bad CSV data (e.g. invalid IDs) now results in a detailed error dialog pointing to the log file.
- Verified that execution failures display a list of specific failed items.
- Verified that the "Checking CSV..." dialog appears correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix: Enhanced Error Handling and Feedback for CSV Import
Motivation
The CSV Import feature had a few "silent failure" modes that made debugging dificult for users:
IOExceptionandParseExceptionerrors during the pre-check phase (ingetItemFromInstance) were caught but not logged or reported, leading to incomplete data loading.MainWindow.javacaused the import result to be overwritten by an empty "final result" object, resulting in a blank error dialog if the pre-check failed.RuntimeException) or failed during the actual update loop, the errors were not aggregated or displayed to the user.Changes
JellyfinImportMetadata.javastartPreCheckto catch genericExceptions and propagate them to the result object.getItemFromInstance, exceptions are now explicitly logged to the differences log file (and system logger) instead of being ignored.startImportto:try-catchblock to handle unexpected crashes.StringBuilderto aggregate specific error messages for failed items (e.g., "Failed to refresh folder ID...").JellyfinResponseStandardmessage if the import fails.MainWindow.javaJDialogwith an indeterminate progress bar during the pre-check phase to indicate activity.processResultwas unconditionally overwritten byimportCSV.getProcessFinalResult()(which was empty at that stage). Now it only updates after a successful import run.try-catchblock aroundworker.get()in the done() method to ensure that any exceptions thrown on the background thread are displayed to the user via aJOptionPane.Testing