Skip to content

Fix: Enhanced Error Handling and Feedback for CSV Import#69

Open
RyanMarr wants to merge 4 commits intoCesarBianchi:mainfrom
RyanMarr:fix/import-error-handling
Open

Fix: Enhanced Error Handling and Feedback for CSV Import#69
RyanMarr wants to merge 4 commits intoCesarBianchi:mainfrom
RyanMarr:fix/import-error-handling

Conversation

@RyanMarr
Copy link
Copy Markdown

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:

  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 Exceptions 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.

## 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.
@CesarBianchi CesarBianchi self-requested a review April 7, 2026 00:39
@CesarBianchi CesarBianchi self-assigned this Apr 7, 2026
@CesarBianchi CesarBianchi added the bug Something isn't working label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants